
November 13th, 2000, 11:24 AM
|
|
Junior Member
|
|
Join Date: Nov 2000
Posts: 0
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Okay, so I'm that lame. hehe...
My bad code was my problem. To anyone with this same question, here is some code that actually works:
//////////////////////////
//READING:
try{
fis = new FileInputStream(getFullPath());
dis = new DataInputStream(fis);
while( dis.available() != 0)
{ System.out.println(dis.readLine());}
// I know, I know...
// readline() is deprecated... : (
dis.close();
}catch(IOException e)
{ System.out.println(e.toString());}
/////////////////////////////////////////
// Write something
FileOutputStream fos = null;
PrintStream p = null;
try{
// Create a new file output stream
fos = new FileOutputStream(getFullPath());
// Create a print stream using your new output stream
p = new PrintStream( fos );
//Write something in the file
p.println ("You are a freak!");
// free up the stream.
p.close();
}catch(IOException e)
{System.out.println("write file error" + e.toString());}
|