🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #1162

about Class FileWriter

#1162
From: Zhilei Ma
Date: Wed, 17 Apr 2002 13:41
37 lines
2133 bytes
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: <3cbd7afe$1_2@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!yellow.newsread.com!bad-news.newsread.com!netaxs.com!newsread.com!news.maxwell.syr.edu!news.algonet.se!algonet!newspeer.clara.net!news.clara.net!peernews!peer.cwci.net!news5-gui.server.ntli.net!ntli.net!newsfeed01.sul.t-online.de!t-online.de!dnews

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,90dc8a5714e91d72,start
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2002-04-17 06:41:17 PST
Reply-To: "Zhilei Ma" <zhilei.ma@iao.fhg.de>
From: "Zhilei Ma" <zhilei.ma@iao.fhg.de>
Newsgroups: borland.public.jbuilder.java.api
Subject: about Class FileWriter
Date: Wed, 17 Apr 2002 15:41:07 +0200
Lines: 39
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 137.251.48.170
Message-ID: <3cbd7afe$1_2@dnews>
X-Trace: dnews 1019050750 137.251.48.170 (17 Apr 2002 06:39:10 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!yellow.newsread.com!bad-news.newsread.com!netaxs.com!newsread.com!news.maxwell.syr.edu!news.algonet.se!algonet!newspeer.clara.net!news.clara.net!peernews!peer.cwci.net!news5-gui.server.ntli.net!ntli.net!newsfeed01.sul.t-online.de!t-online.de!dnews