Results 1 to 2 of 2

Thread: How to read and write files using java?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Posts
    27

    How to read and write files using java?

    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.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: How to read and write files using java?

    1) Use code tags.
    2) The line that gives you the error does not appear in what you posted.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width