Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save java file 2

Status
Not open for further replies.

borntorun

MIS
Oct 16, 2003
82
GB
HI,

I would like to pass a string to a java program and then save this to the file system, in a specific location.

It should overwrite any file that is existing but wait if the file is being read.

Can i use the file class?

Thanks.
 
Something like:
Code:
     try {PrintWriter outF = new PrintWriter(new FileWriter ([red]<file name>[/red],[b]false[/b]));
                   outF.println([red]<whatever>[/red]);
                   outF.close();
      }
      catch (IOException eio) {System.out.println(eio);}

The false specifier says not to append.

_________________
Bob Rashkin
 
Note that Bong's example is for ASCII data only.

Look at the java.io package - there are lots of streams to choose from - the base one being FileOutputStream for file based operations.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top