Hello, I have problem.
I need to read a line like this from a file: 5 Chair 12.49 EDIT: I want to be able to have more lines of data.
I need to separate each word/number into different data types. First one is an int, second is a String, third is a double. Then I need to have them formatted like this: Item: Chair Price: $12.49 Quantity: 5
Now I know how to format, the only problem I am having is parsing the string elements into their respected data types (int, string, double).
I've tried:
String [] lines = lineInput.split(" ");
for(String displayLines : lines) {
bufferedWriter.write(displayLines);
bufferedWriter.newLine();
System.out.println(displayLines);
}
but that only separates each string into a new line and I couldn't for the life of me figure out how to have each line check if it's an int, string or double.
Then I was messing with substring, but couldn't get that to work. I even thought of using mod % function and if:
if(lines.length % 2 == 0) {it's a string};
but that would only work for the first line.
Please believe me when I say i've tried this on my own and am not just making some half-trying effort. I just giving up. StackOverFlow, you're my only hope :(