Amir Afghani
Amir Afghani

Reputation: 38561

Eclipse project with file resources that I'd like to write out on application start

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

Answers (1)

prunge
prunge

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

Related Questions