• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Scanner problem on unix  RSS feed

 
Rashmee Kulkarni
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I am facing some problem with java scanner on unix . The same piece of code is working fine on windows environment.

On Unix nextLine() method is returning only half of the line.I have checked file 100's of times for format but file is in correct unix format.
And after that line it could not find out any other line present after that line.

Can you guys please help me out?





Sorry ! but I cant post a file! Its confidential..but it is comma seperated file..
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My crystal ball is in for servicing and I won't get it back until Monday so I can't see your code or your file content. Can you post the code and a fragment of the offending file?
 
Rashmee Kulkarni
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James Sabre wrote:My crystal ball is in for servicing and I won't get it back until Monday so I can't see your code or your file content. Can you post the code and a fragment of the offending file?

 
Rashmee Kulkarni
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James Sabre wrote:My crystal ball is in for servicing and I won't get it back until Monday so I can't see your code or your file content. Can you post the code and a fragment of the offending file?


Posted my code...
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rashmee Kulkarni wrote:Hi Guys,


Sorry ! but I cant post a file! Its confidential..but it is comma seperated file..


Surely you can post a dummy file!

You say half is missing. Does that mean the lines are truncated or that you only see alternate entries after splitting the line?
 
Rashmee Kulkarni
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James Sabre wrote:
Rashmee Kulkarni wrote:Hi Guys,


Sorry ! but I cant post a file! Its confidential..but it is comma seperated file..


Surely you can post a dummy file!

You say half is missing. Does that mean the lines are truncated or that you only see alternate entries after splitting the line?


eg. DNGA,AG,\DNGA,dn,NG,6262,NA,1,2,HC,1,L,N,M,M V,na,,01-Mar-2009,,NOCODE,UD,M is the line in file and nextLine() returns only DNGA,AG,\DNGA,dn,NG,6262,NA,1,2,HC,1
For the lines before this line,method works fine...
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rashmee Kulkarni wrote:

eg. DNGA,AG,\DNGA,dn,NG,6262,NA,1,2,HC,1,L,N,M,M V,na,,01-Mar-2009,,NOCODE,UD,M is the line in file and nextLine() returns only DNGA,AG,\DNGA,dn,NG,6262,NA,1,2,HC,1
For the lines before this line,method works fine...


This line works OK for me processing with your code. What fails when I run your code is if I have an empty line! you should test the result of the split() to make sure there are enough elements in it. Yes - I am using Linux (Ubuntu 10.10 with JDK1.6.0_22)

I don't like your exception handling since any error will try to read the next line even if there isn't one.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!