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?
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!