Reputation: 38561
I have an Eclipse plugin project that has several file resources that I would like to write out to disk (if they don't already exist) when the application starts up. Is there an easy way to do this or do I have to essentially read the file as a resource and write it out using a FileWriter or some such?
Upvotes: 1
Views: 184
Reputation: 23268
or do I have to essentially read the file as a resource and write it out using a FileWriter or some such
Pretty much, but the Commons IO library has the FileUtils.copyURLToFile() method that makes this trivial.
FileUtils.copyURLToFile(MyClass.class.getResource("abc.txt"), new File("resources/abc.txt"));
Upvotes: 2