File I/O In Java
I know this sounds odd, but I just can''t seem to make a file! I''ve tried the java.io.* package, resorted the the WFC and still nothing... Would anybody be able to show me how to make a file? Any file.. just create a file, print a number to it and then load it again and get that number... is it too much to ask from a language named after coffe?
this is my current attempt using the WFC..
// I would like it in the
// code base directory, but im willing to settle for now
String loadFile = "c:\\saveGame\\";loadFile = loadFile + charName + ".dds"
try {
File file;
file = File.create (saveFile);
file.writeInt (x);
file.close ();
} catch (IOException ioe) {
// nothing, just work!
}
is it even possible for java to create a file? Even with the WFC? I''m kinda dying here, anything would help. Thanks!
-Cajun
Christopher.Smith@Trinity.edu
September 28, 2000 11:01 PM
Used BufferedWriter for output and BufferedReader for input.
Something like this:
Something like this:
BufferedWriter out = new BufferedWriter( new FileWriter("file.name" ));out.write( number );out.flush();out.close();BufferedReader in = new BuffereeReader( new FileReader( "file.name" ));number = in.read();in.close();
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement