I have this simple java code:
import java.nio.file.*;
import java.io.*;
public class Write {
public static final String PATH = "/home/user/Desktop/hello.txt";
public static void main(String[] argv) {
Path path = Paths.get(PATH);
OutputStream out;
try {
out = Files.newOutputStream(path, CREATE, APPEND);
} catch (IOException e) {
System.out.println("Caught IOException: "+e.getMessage());
}
}
}
which wont compile due to this error:
Write.java:14: error: cannot find symbol
out = Files.newOutputStream(path, CREATE, APPEND);
^
symbol: variable CREATE
location: class Write
Write.java:14: error: cannot find symbol
out = Files.newOutputStream(path, CREATE, APPEND);
^
symbol: variable APPEND
location: class Write
2 errors
Usually this means that I've forgotten to import some stuff. I even tried to add:
import java.nio.file.StandardOpenOption
But I get the same error.
EDIT: Ok so, I've solved my problem by following @rmlan advice. I did miss those constants. Thanks.