Creating a file - What is wrong here? [message #685739] |
Sat, 18 June 2011 17:54  |
Eclipse User |
|
|
|
Hi,
I am trying to understand what the problem is with accessing a file system resource. I did quite a bit of Googling, but couldn't find anything on this.
Below is the code I am experimenting with. It always throws a FNFE, also when I change it to input stream and point it to an existing file.
I am clearly missing something, but what?
URL url = FileLocator.toFileURL(Platform.getBundle(""my.bundle.id).getEntry("./../.."));
String urlString = url.toString();
IPath urlPath = new Path(urlString).append("myfile.txt");
File file = urlPath.toFile();
file.createNewFile(); <----- FileNotFoundException
// InputStream fis = new FileInputStream(file); <-------- FNFE
OutputStream os = new FileOutputStream(file);
os.write("Hello".getBytes());
os.flush();
os.close();
} catch (IOException e) {
LOG.error(e.getClass() + ": " + e.getMessage());
}
Your help is highly appreciated.
Kind Regards,
Erwin
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.17384 seconds