Results 1 to 2 of 2
Thread: skipping input
- 02-11-2008, 05:34 AM #1Member
- Join Date
- Feb 2008
- Rep Power
Hi, every1. I am new to java and i need to read in a text file.
This is my text file.
Name = Jack
Address = 123 Ripley, Singapore 7666322
I need to read in the "Jack" and the address without reading in the "Name =" and the "Address =" using Scanner.
This is my method:
Scanner input = new Scanner(new File(fileName));
String name = input.nextLine().toUpperCase();
String address = input.nextLine();
new Customer(name, address);
System.out.println(numOfCustomers+" records read.");
can anybody suggest a better way of doing it if there is more than 2 variables?
- 02-12-2008, 08:09 PM #2
Welcome to the Java Forums windie
Your logic should simply be to the tune of:
i) read in the line
a) read up to equals sign, disregard
b) read past equals sign, true
You can incorporate that logic into your code with a multitude of API methods available to you.
See you around!
- By karma in forum New To JavaReplies: 8Last Post: 08-13-2010, 09:32 PM
- By new_1 in forum New To JavaReplies: 6Last Post: 12-25-2007, 08:38 AM
- By smilejava in forum New To JavaReplies: 5Last Post: 11-12-2007, 08:29 AM
- By smilejava in forum New To JavaReplies: 1Last Post: 11-05-2007, 01:32 PM
- By bilal_ali_java in forum Advanced JavaReplies: 0Last Post: 07-21-2007, 08:46 AM