is this IOException problematic?
My program runs fine but I keep getting this error message printed:
Code:
java.io.FileNotFoundException: C:\ozzypos\orders\2011.03.29_1.pos (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:70)
at ozzypos.IOWrite.writeNewOrders(IOWrite.java:41)
Even though that happens every time i save a file, the files are still saved and the program continues to run fine. I was wondering why this is happening?
I suspected that it is due to me locking the files, or because the folder already exists? but i don't really know so any help greatly appreciated.
this is the relevent code:
Code:
public static String SAVE_DIRECTORY = "C:/ozzypos/";
public static void writeNewOrders(Order order) {
String filename = createDirectory("orders/") + String.format(Date.getFormattedDate(false)
+ "_%d.pos",order.getOrderID());
FileOutputStream fos = null;
ObjectOutputStream out = null;
try {
fos = new FileOutputStream(filename); [COLOR="DarkGreen"]//Line 41[/COLOR]
out = new ObjectOutputStream(fos);
out.writeObject(order);
out.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
public static String createDirectory(String subdirectory) {
String finalDirectory = SAVE_DIRECTORY + subdirectory;
try {
new File(finalDirectory).mkdirs();
String cmd="attrib +h +s " + finalDirectory.concat("*") + " /S";
Runtime.getRuntime().exec(cmd);
} catch (Exception ex) {
ex.printStackTrace();
}
return finalDirectory;
}