Results 1 to 2 of 2

Thread: readLine() and .dat

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Posts
    103

    readLine() and .dat

    hey there!
    how do i read each line in a .dat file? is it the same way as reading a .txt file?

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    As long as the information in the file is just plain text, it doesn't matter what the extension of the file is...
    Code:
    import java.io.*;
    
    public class Test
    {
    	public static void main(String args[])
    	{
    		try
    		{
    			BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("c:\\status.txt")));
    			String s = "";
    
    			while ((s=br.readLine())!=null)
    			{
    				System.out.println(s);
    			}
    		} catch (Exception e){}
    
    	}
    
    }
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

Posting Permissions

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



Click Here to Expand Forum to Full Width