PDA

Click to See Complete Forum and Search --> : How to read and write files using java?


asenthil
Feb 7th, 2007, 12:22 AM
i'm trying to read and write files using java...

some errors occurs when i'm trying this code..

Error in java: Cannot find symbol
location: class java.io.FileOutputStream
FileOutputStream fout = new FileOutputStream(outputFile);
^
import java.io.*;

public class Copy {
public static void main(String[] args) throws IOException {
// create two file references
File inputFile = new File("D:/1.txt");
File outputFile = new File("D:/2.txt");

// create two File Streams
FileReader in = new FileReader(inputFile);
FileWriter out = new FileWriter(outputFile);

// read one file and write it out to another
int c;

while ((c = in.read()) != -1)
out.write(c);

// close both files
in.close();
out.close();
}
}

What i have to do for this?

now only i'm learning java...
thats y...

senthil.

CornedBee
Feb 7th, 2007, 05:42 AM
1) Use code tags.
2) The line that gives you the error does not appear in what you posted.