🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #8359

Re: Write a line

#8359
From: Andrew Shrosbree
Date: Mon, 26 Mar 2001 23:02
100 lines
3923 bytes
--------------5473098D3B73CBF28D0AE4F1
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Does this help? I use it to maintain a text-file registry.

  static public void saveRegistry() {
    try {
      FileWriter oFW = new FileWriter( "registry.txt" );

      for ( Enumeration e = getRegistry().elements(); e.hasMoreElements(); ) {
        oFW.write( (String)e.nextElement() + System.getProperty(
"line.separator" ) );
      }

      oFW.close();
    }
    catch(IOException E){
      System.out.println(E);
    }
  }


Ahmad Noori wrote:

> Hello,
>
> I have a txt file that I want to write to it one line at a time.  I
> sometimes want to write in the middle of the file and sometimes at the
> beginning.  Using write(string, int, int), will replace the whole file,
> readline() reads one line at a time, does anyone knowof a  method that
> could write one line at a time.
>
> Thanks a lot
>
> Ahmad Noori
> SAIC

--
Andrew N. Shrosbree
Project Manager and Technical Architect
Collaborative Centre for eHealth
University of Ballarat
Victoria, Australia
Tel: +61 (0)3 5327 9896
Fax: +61 (0)3 5327 9307
Mob: +61 (0)415 645 291


--------------5473098D3B73CBF28D0AE4F1
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Does this help? I use it to maintain a text-file registry.
<p>&nbsp; static public void saveRegistry() {
<br>&nbsp;&nbsp;&nbsp; try {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileWriter oFW = new FileWriter( "registry.txt"
);
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for ( Enumeration e = getRegistry().elements();
e.hasMoreElements(); ) {
<br><font color="#CC0000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; oFW.write(
(String)e.nextElement() + System.getProperty( "line.separator" ) );</font>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; oFW.close();
<br>&nbsp;&nbsp;&nbsp; }
<br>&nbsp;&nbsp;&nbsp; catch(IOException E){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(E);
<br>&nbsp;&nbsp;&nbsp; }
<br>&nbsp; }
<br>&nbsp;
<p>Ahmad Noori wrote:
<blockquote TYPE=CITE>Hello,
<p>I have a txt file that I want to write to it one line at a time.&nbsp;
I
<br>sometimes want to write in the middle of the file and sometimes at
the
<br>beginning.&nbsp; Using write(string, int, int), will replace the whole
file,
<br>readline() reads one line at a time, does anyone knowof a&nbsp; method
that
<br>could write one line at a time.
<p>Thanks a lot
<p>Ahmad Noori
<br>SAIC</blockquote>

<p>--
<br>Andrew N. Shrosbree
<br>Project Manager and Technical Architect
<br>Collaborative Centre for eHealth
<br>University of Ballarat
<br>Victoria, Australia
<br>Tel: +61 (0)3 5327 9896
<br>Fax: +61 (0)3 5327 9307
<br>Mob: +61 (0)415 645 291
<br>&nbsp;</html>

--------------5473098D3B73CBF28D0AE4F1--
Technical Details
Message-ID: <3ABFCA81.52994AC9@ballarat.edu.au>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!hermes2.visi.com!news-out.visi.com!news-out.visi.com!hermes.visi.com!unlisys!news.snafu.de!news1.ebone.net!news.ebone.net!newsfeed.freenet.de!news1.dtag.de!news.gwi-ag.com!dnews!141.132.70.47
References: <3ABF903A.54E8FC0@SAIC.COM>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,95abce2b73e81abc
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-03-26 18:06:04 PST
Message-ID: <3ABFCA81.52994AC9@ballarat.edu.au>
Date: Tue, 27 Mar 2001 09:02:25 +1000
From: Andrew Shrosbree <A.Shrosbree@ballarat.edu.au>
Organization: University of Ballarat
X-Mailer: Mozilla 4.73 [en] (Win98; I)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language
Subject: Re: Write a line
References: <3ABF903A.54E8FC0@SAIC.COM>
Content-Type: multipart/alternative;
 boundary="------------5473098D3B73CBF28D0AE4F1"
NNTP-Posting-Host: 141.132.70.47
X-Trace: 26 Mar 2001 15:04:35 -0800, 141.132.70.47
Lines: 101
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!hermes2.visi.com!news-out.visi.com!news-out.visi.com!hermes.visi.com!unlisys!news.snafu.de!news1.ebone.net!news.ebone.net!newsfeed.freenet.de!news1.dtag.de!news.gwi-ag.com!dnews!141.132.70.47