GIDForums  

Go Back   GIDForums > Computer Programming Forums > Java Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 07-Feb-2007, 00:23
asenthil asenthil is offline
New Member
 
Join Date: Dec 2006
Posts: 24
asenthil is on a distinguished road

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..

JAVA 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...

bye.
senthil.
Last edited by LuciWiz : 07-Feb-2007 at 03:29. Reason: Please insert your Java code between [java] & [/java] tags
  #2  
Old 08-Feb-2007, 12:11
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,017
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: How to read and write files using java?


How about posting the ALL the code.

It is not clear that this statement:
JAVA Code:
FileOutputStream fout = new FileOutputStream(outputFile);
should be part of that class, because the compliler found it, but it's not in your code -- it appears that it was just included as part of the error message for the post. Unless it appears elsewhere...
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
 
 

Recent GIDBlogI?m Home by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Airport Log program using 3D linked List : problem reading from file batrsau C Programming Language 11 29-Feb-2008 08:44
How to read the contents of a webpage and write it to a file? asenthil MS Visual C++ / MFC Forum 3 23-Jan-2007 22:04
Use VB or VC ++ to read/ write tiff file confused_pig MS Visual C++ / MFC Forum 0 26-Jan-2005 10:10
which language ? onauc C++ Forum 2 19-Nov-2004 03:53

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 03:43.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.