+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Senior Member
    Join Date
    May 1999
    Location
    Denver, CO, USA
    Posts
    775

    adding info to a txt file w/ java and then saving it...

    hey all, i know you can do it, but the truth be told... i don't want to spend the time figuring it out myself so i figure i'll ask you all

    I want to write a java program that opens and reads data from a txt file. then I want it to open a different file and report the results of that data in the new text file. finally i want it to close and save the 2nd txt file with the new information added.... how do i do this??

    thanks
    -Z

  2. #2
    Banned qball's Avatar
    Join Date
    Oct 1999
    Location
    Rockaway, NJ 07866
    Posts
    1,730
    a wee bit lazy, aren't we?

    anyway:
    //to read from file
    //vars
    String textFileIn = null;
    String line = null;

    //how you determine filename
    //can be as easy as arg[0]
    BufferedReader textIn = new BufferedReader(new FileReader(new File(textFileIn)));

    //to write to file
    String textFileOut = null;
    String workingString = null;
    //how you determine textFileOut is up to you
    //how you determine workingString is up to you
    BufferedWriter textOut = new BufferedWriter(new FileWriter(new File(textFileOut)));
    textOut.write(workingString);
    textOut.close();

    [This message has been edited by qball (edited 09-08-2001).]

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts







New Security Features Planned for Firefox 4
Another Laptop Theft Exposes 21K Patients' Data
Oracle Hits to Road to Pitch Data Center Plans
Microsoft Preps Array of Windows Patches
Microsoft Nears IE9 Beta With Final Preview
Simplified Analytics Improve CRM, BI Tools
Android Passes RIM as Top Mobile OS in 2Q
VMware Updates Hyperic System Management
File Monitoring Key to Enterprise Security
LinkedIn Snaps Up SaaS Player mSpoke