Advertisement
Guest User

Untitled

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