Jun 12, 2006 #1 borntorun MIS Joined Oct 16, 2003 Messages 82 Location 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.
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.
Jun 12, 2006 1 #2 Bong Programmer Joined Dec 22, 1999 Messages 2,063 Location US 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 Upvote 0 Downvote
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
Jun 12, 2006 1 #3 sedj Programmer Joined Aug 6, 2002 Messages 5,610 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 http://www.primrose.org.uk Upvote 0 Downvote
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 http://www.primrose.org.uk