🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Modifying data in a text file

#17291
From: Steve Schafer (TeamB)
Date: Thu, 26 Nov 1998 00:00
22 lines
1222 bytes
On Wed, 25 Nov 1998 13:11:37 -0800, Michael Andres
<andr0023@tc.umn.edu> wrote:

>   A presumably easy question.  What is the best way to modify an
>existing line of text in a file?  I need to create a method to change a
>users password.  They file is as such:
>
>user1 passwd1
>user2 passwd2
>
>How do I change, for example, user1's password to:
>
>user1 newpasswd
>
>leaving the rest of the file unchanged?

Unless you can guarantee that the two passwords will be exactly the
same length, you really have no choice but to completely read in the
original file, and write out the new file the same way, modifying just
the one record as you do so.

-Steve
Technical Details
Message-ID: <3688a2f2.147216797@90.0.0.40>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <365C7288.E1E3B20E@tc.umn.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,7ee9637438b194e8
X-Google-Attributes: gidf74b3,public
From: pandeng@telepath.com (Steve Schafer (TeamB))
Subject: Re: Modifying data in a text file
Date: 1998/11/26
Message-ID: <3688a2f2.147216797@90.0.0.40>
X-Deja-AN: 415729373
Content-Transfer-Encoding: 7bit
References: <365C7288.E1E3B20E@tc.umn.edu>
Content-Type: text/plain; charset=us-ascii
Organization: TeamB
Mime-Version: 1.0
Reply-To: pandeng@telepath.com
Newsgroups: borland.public.jbuilder.java.language