How to write a file to the same directory of the class file?# Java - 爪哇娇娃
i*1
1 楼
Da xia,
My applications has different packages, and I want a different property file
in each package. How can I read/write some files located at the same directory
of the class file?
I can use:
InputStream in = this.getResource("filename").openStream();
To get the file content sucessfully.
But how can I change the file content? I tried
FileOutputStream out = new FileOutputStream(this.getResource("filename").
toString());
this.getResource("filename").toString() return a String like file:C://...
My applications has different packages, and I want a different property file
in each package. How can I read/write some files located at the same directory
of the class file?
I can use:
InputStream in = this.getResource("filename").openStream();
To get the file content sucessfully.
But how can I change the file content? I tried
FileOutputStream out = new FileOutputStream(this.getResource("filename").
toString());
this.getResource("filename").toString() return a String like file:C://...