I get this error when i write to my C drive using an ObjectOutputStream
List<String> strings = new ArrayList<String>();
strings.add("test1");
strings.add("test2");
strings.add("test3");
IO.IO.writeListToFile("C:\\Users\\coconnor\\Documents\\Java\\ToolKit\\", strings);
public static void writeListToFile(String location, List<?> list) {
ObjectOutputStream p = null;
File f = new File(location);
try {
p = new ObjectOutputStream(new FileOutputStream(f));
p.writeObject(list);
p.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
java.io.FileNotFoundException: C:\Users\coconnor\Documents\Java\ToolKit (Access is denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
at IO.IO.writeListToFile(IO.java:61)
at Testing.IOTest.<init>(IOTest.java:13)
at Testing.IOTest.main(IOTest.java:18)
Thanks in advance