Article View: borland.public.jbuilder.java.api
Article #1183Re: about Class FileWriter
From: Nabin Thomas
Date: Thu, 18 Apr 2002 16:46
Date: Thu, 18 Apr 2002 16:46
71 lines
3023 bytes
3023 bytes
> import java.io.*;
>
> public class FileWriterDemo
> {
> public static void main( String args[] )
> {
> try
> {
> String path = System.getProperty( "user.home" )
+ System.getProperty( "file.separator" )
> + "fileWriter.txt";
> File fileName = new File( path );
> FileWriter fw = new FileWriter( path, true );
> String s = "Hallo Welt geht in eine Datei." + System.getProperty(
> "line.separator" );
> fw.write( s );
>
> fw.close();
> } catch ( IOException e ) {
> System.out.println( "File can not to be saved." );
> }
> }
> }
>
"Zhilei Ma" <zhilei.ma@iao.fhg.de> wrote in message
news:3cbd7afe$1_2@dnews...
> hi all,
>
> i try to write a progarmm to save text in a specific directory, and the
text
> should not be overwrited but appended in a text file. so i choosed class
> FileWriter. the codes are follows:
> import java.io.*;
>
> public class FileWriterDemo
> {
> public static void main( String args[] )
> {
> try
> {
> String path = System.getProperty( "user.home" ) +
> + "fileWriter.txt";
> File fileName = new File( path );
> FileWriter fw = new FileWriter( path, true );
> String s = "Hallo Welt geht in eine Datei." + System.getProperty(
> "line.separator" );
> fw.write( s );
>
> fw.close();
> } catch ( IOException e ) {
> System.out.println( "File can not to be saved." );
> }
> }
> }
>
> but the name of the text file is username+"filewriter.txt".for exsample,
the
> username is Zhilei, then the file name i got is "Zhileifilewriter.txt".but
i
> want to make the file name to be "filewriter.txt". how can i solve this
> problem. and how can i save the file in a dir that i named, for instance,
i
> want to save it in "C:\Myworks\Output".
>
> regards
>
> Zhilei Ma
>
>
Technical Details
Message-ID:
<3cc194ad_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!207.217.77.43.MISMATCH!newsfeed1.earthlink.net!newsfeed.earthlink.net!news-hog.berkeley.edu!ucberkeley!logbridge.uoregon.edu!gestalt.direcpc.com!telocity-west!TELOCITY!news-out.spamkiller.net!propagator2-maxim!propagator-maxim!news-in.spamkiller.net!news02.tsnz.net!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnewsReferences:
<3cbd7afe$1_2@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,90dc8a5714e91d72 X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2002-04-20 09:28:45 PST From: "Nabin Thomas" <May add to messenger as nabinthomas@hotmail.com> Newsgroups: borland.public.jbuilder.java.api References: <3cbd7afe$1_2@dnews> Subject: Re: about Class FileWriter Date: Thu, 18 Apr 2002 22:16:54 +0530 Lines: 73 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 NNTP-Posting-Host: 202.9.167.49 Message-ID: <3cc194ad_1@dnews> X-Trace: dnews 1019319469 202.9.167.49 (20 Apr 2002 09:17:49 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!207.217.77.43.MISMATCH!newsfeed1.earthlink.net!newsfeed.earthlink.net!news-hog.berkeley.edu!ucberkeley!logbridge.uoregon.edu!gestalt.direcpc.com!telocity-west!TELOCITY!news-out.spamkiller.net!propagator2-maxim!propagator-maxim!news-in.spamkiller.net!news02.tsnz.net!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews