Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1.  
  2.     private static void copyFileFromJarToDirectory(String filename)
  3.     {
  4.         String DIR = getDataFolder();
  5.  
  6.         File outFile = new File(DIR +  filename);
  7.         if (!outFile.exists())
  8.         {
  9.  
  10.             URL url = Main.class.getResource("/" + filename);
  11.             System.out.println(url.getPath());
  12.             File file = null;
  13.             try {
  14.                 file = new File(url.toURI());
  15.                
  16.                
  17.                 try {
  18.                     outFile.getParentFile().mkdirs();
  19.                     outFile.createNewFile();
  20.                     FileUtils.copyFile(file, outFile);
  21.                 } catch (IOException e) {
  22.                     // TODO Auto-generated catch block
  23.                     e.printStackTrace();
  24.                 }
  25.             } catch (URISyntaxException e) {
  26.             }
  27.         }
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement