Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By eRaaaa

Thread: scanning lines from notepad, by creating a loop "while(input_line=NULL) {"

  1. #1
    noobplus's Avatar
    noobplus is offline Senior Member
    Join Date
    Feb 2012
    Location
    chennai,south of India(south east of asia)
    Posts
    232
    Rep Power
    3

    Default scanning lines from notepad, by creating a loop "while(input_line=NULL) {"

    Java Code:
     
    while(input_line!=null)
    	    {	
    	    	 System.out.println("---------------");
    	    	 System.out.println("Line No:"+TotalLineCount);//"TotalLineCount" is incremented after each line-scanning
    	    	
    	    	
    	    	input_line =in.readLine();
    	    	input_line=input_line.replaceAll("\"","");
    	    	input_split = input_line.split(" ");    	   	
    	    	
    	    	 System.out.println("Input Line:"+input_line);
    	    	 System.out.print(input_split.length);
    	    	 System.out.print("x"+input_split[0]);
    	    	 System.out.print("y"+input_split[2]);
    	    		        
    	    	TotalLineCount++; //at the final line, it reaches the file-length. and the next line is null. 
                                             //but the while loop continues.. cuz, input_line is present yet. 
                                             //Thus I get an error during run-time "nullpointerexception"
                                             //Is there another looping technique?
    	    	
    	    }
    thx
    dhilip

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default Re: scanning lines from notepad, by creating a loop "while(input_line=NULL) {"

    while((input_line=in.readLine()) !=null)

    then you can delete line 7.
    noobplus likes this.

  3. #3
    noobplus's Avatar
    noobplus is offline Senior Member
    Join Date
    Feb 2012
    Location
    chennai,south of India(south east of asia)
    Posts
    232
    Rep Power
    3

    Default Re: scanning lines from notepad, by creating a loop "while(input_line=NULL) {"

    Quote Originally Posted by eRaaaa View Post
    while((input_line=in.readLine()) !=null)

    then you can delete line 7.
    thx very much.. I'm working on that.

    thx
    dhilip

  4. #4
    noobplus's Avatar
    noobplus is offline Senior Member
    Join Date
    Feb 2012
    Location
    chennai,south of India(south east of asia)
    Posts
    232
    Rep Power
    3

    Default Re: scanning lines from notepad, by creating a loop "while(input_line=NULL) {"

    Quote Originally Posted by eRaaaa View Post
    while((input_line=in.readLine()) !=null)

    then you can delete line 7.
    ive run ur code. it gives the no.of.lines exact value , thx again

    thx
    dhilip

Similar Threads

  1. Replies: 1
    Last Post: 02-01-2012, 08:37 PM
  2. Replies: 9
    Last Post: 08-03-2011, 05:05 PM
  3. An "if" statement inside a "for" loop?
    By soccermiles in forum New To Java
    Replies: 18
    Last Post: 04-20-2010, 03:44 AM
  4. Count lines cointaining "word" in input file
    By gwithey in forum New To Java
    Replies: 5
    Last Post: 04-02-2009, 05:23 AM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 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
  •