NoSuchElementException in Linux
Greetings all. I have a rather interesting problem with the Scanner class, and Google hasn't been able to help.
Some background: I just bought a new laptop for college and am dual-booting Linux and Vista (because it comes standard with Vista). On my old laptop I had XP, so I used that primarily for programming, but now that I have to have Vista I'm using mainly Ubuntu for coding.
I transferred over my files and tried to execute one of my programs. The particular section giving the error is supposed to read in a configuration file ("config.inf") and set the look and feel and other options based on what it finds; the part of config.inf it's looking for comes after a '#' character, so it reads through until it gets there, reads the next line, and acts on that line's contents. On XP it works perfectly; on Ubuntu the Scanner class doesn't seem to want to work. This:
returns a NoSuchElementException at the "temp=in.nextLine();" right after the while loop. I've tried to debug it and for some reason it thinks config.inf is empty; printing the value of temp has no effect because the while loop apparently never executes.
Scanner in=new Scanner(new File("config.inf")).useDelimiter("\r|\r\n|\n");
//do other stuff
My best guess was that the Windows line separator difference ("\r\n" instead of '\n') is the problem, so I set the Scanner to use both kinds of delimiters, but that didn't work. If that is the issue, and I just didn't fix it correctly, does anyone know how to fix that? If not, does anyone know what the problem actually is?
Thanks in advance for your assistance.
By Gwen Smith in forum vb.announcements
Last Post: 07-21-2003, 03:17 PM
By Elena in forum Careers
Last Post: 07-11-2002, 12:40 AM
By Kevin Moore in forum .NET
Last Post: 02-27-2002, 04:06 PM
By Robert Radina in forum Talk to the Editors
Last Post: 06-15-2000, 08:28 AM
By Kevin Gadd in forum Talk to the Editors
Last Post: 05-06-2000, 07:27 AM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center