Results 1 to 2 of 2

Thread: Read Line

  1. #1
    CODinacup is offline Member
    Join Date
    Sep 2012
    Posts
    13
    Rep Power
    0

    Default Read Line

    Hello Everybody i have a .txt file that is loaded by my program and the first line is read and printed to a new file. In the resource .txt file everything has "" around what should stay the same, and +example_var+ where a String var should be placed. The generated file does not replace +example_var+ with the correct var, it just puts in "STAY SAME TEXT"+example_var+"STAY SAME TEXT". My goal is to replace the +example_var+ with the actual value of the String var exmaple_var. Some of the code below.

    Java Code:
    	   File f = new File("weap_file.txt");
    	   BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(f), "US-ASCII"));        
    	   String line = br.readLine();
    	   BufferedWriter Wwriter = null;
    		try
    		{
    			Wwriter = new BufferedWriter( new FileWriter( folder_path+global.Fname ));
    			Wwriter.write(line);
    
    		}

  2. #2
    Ronin is offline Senior Member
    Join Date
    Oct 2010
    Posts
    384
    Rep Power
    5

    Default Re: Read Line

    The StringBuilder class could be what you need.
    #StringBuilder (Java 2 Platform SE 5.0)

    If you are feeling a litle bit more adventurous you could also look into using regex.

    EDIT: Here is the documentation for Java 7.
    StringBuilder (Java Platform SE 7)

    Regards.
    Last edited by Ronin; 04-02-2013 at 11:57 AM.

Similar Threads

  1. How to read a 2d array file line by line
    By jsoeung in forum New To Java
    Replies: 35
    Last Post: 04-18-2012, 03:23 PM
  2. Replies: 16
    Last Post: 09-17-2011, 02:41 AM
  3. Line Reader changeing to read 1 line
    By Javanooby in forum New To Java
    Replies: 15
    Last Post: 05-10-2011, 04:34 AM
  4. Replies: 1
    Last Post: 02-13-2011, 03:09 PM
  5. Replies: 4
    Last Post: 09-10-2009, 10:18 AM

Posting Permissions

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