modmouse Posted January 4, 2012 Share Posted January 4, 2012 Main.java public static void saveAsHandler() throws IOException, DishException { String fileName = StringIO.ask("file name: "); myMenu.saveAs(fileName); } public static void openHandler() throws IOException, DishException, ClassNotFoundException { String fileName = StringIO.ask("file name: "); myMenu.open(fileName); }==========================Menu.java public void saveAs (String aFilename) throws IOException { FileOutputStream outFile = new FileOutputStream (aFilename); ObjectOutputStream itemsFile = new ObjectOutputStream (outFile); itemsFile.writeObject(menu); itemsFile.writeObject(codes); itemsFile.close(); } public void open (String aFilename) throws IOException, ClassNotFoundException { FileInputStream inFile = new FileInputStream (aFilename); ObjectInputStream itemsFile = new ObjectInputStream (inFile); menu = (Vector)itemsFile.readObject(); codes = (Vector)itemsFile.readObject(); itemsFile.close(); }[/CODE]At the moment files are saved in the same directory as the program has been run from but when I burn it to cd of course this is not possible.I've seen examples but I cannot work out where things like[CODE]("Z:\\results\\results.txt"); or ("z:\\results.txt"); or ("z:/results.txt");[/CODE] are supposed to be placed to save a file created by the java application to a pre determined location. Or even one set by the user. Quote Link to comment Share on other sites More sharing options...
Sitwon Posted January 26, 2012 Share Posted January 26, 2012 I'm not sure I understand your question. You want to ALWAYS save the file to "z:\results.txt"? Or do you want to user to select the location where it should be saved? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.