Hello! I try to create file with java.io.FileOutputStream on visual studio code. Below is the sample code.
File outputFile = new File("test.txt");
OutputStream os = new FileOutputStream(outputFile, true);
But the code throws the java.io.FileNotFoundException exception. Before I use the visual studio code, I used the eclipse ide and this code works without any exception. Are there any options which give the file-creation-permission in visual studio code? For your information, my vs code is system installer version, not user installer.
Top comments (1)
You are trying to open a file from the a relative path (see: absolute vs relative path), more specifically you are trying to open a file from the current working directory. The current working directory might change depending on how you program is executed. You can see what is your current working directory with the following line:
This should output the location of the current working directory. What you have to do is either move your file there in that directory or adjust the path in your
new File("<adjust this>")
.