• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Java Scanner problem on unix

 
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..
 
Ranch Hand
Posts: 781
Netbeans IDE Ubuntu Java
  • 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
Netbeans IDE Ubuntu Java
  • 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
Netbeans IDE Ubuntu Java
  • 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.
 
Something about .... going for a swim. With this tiny ad ...
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic