I have a program where I have a text file, I have to read that text file and display output in term of returning product id to return product object with properties id,name,qty,price. But i have to do it using string tokenizer. If anybody has any idea regarding this please share.. text file contains following data:
id-name-qty-price
101-TV-80-9999
102-laptop-70-898989
103-tablet-50-8888
This is what I have attempted up till now I am able to display data but I am facing problem displaying output:
public static void main(String[] args) throws FileNotFoundException {
// TODO code application logic here
FileReader r = new FileReader("product.txt");
String [] lines = new String[100];
try{
BufferedReader br = new BufferedReader(r);
int x = 0;
String s;
while((s = br.readLine()) != null){
lines[x] = s;
x++;
}
}
catch(IOException e) {
System.exit(0);
}
for(String st: lines)
System.out.println(st);
}
}