Hello all, its that time again! Where i ask a programming question on the forum and see if anyone is able to help. Mainly due to google failing me. pahahaha xD
So here's the question. I have a .txt file with alot of junk within it. If you want an example its basically like this.
yeah..... basically, i want to get the values next to "product", "price" and "tax" without including literally the words product, price, tax. In my output. I can't actually go line by line taking out a specific string, because the pattern could be just about anywhere within the file. I am unsure what syntax or methods to use, i get the logic, and i can easily output the file itself, but i am just not sure how to manipulate what i have.
I have tried stringtokenizer, stringsplit, if statements, and for loop with delimiter, but nothing seems to be working.
If you want little bit of my code of what i have, of what actually works, it would be this.
Any ideas?
So here's the question. I have a .txt file with alot of junk within it. If you want an example its basically like this.
fhdidjnfjdnfjdngjufdnjgn product: apple, price: $5.00, tax: $0.25 ndjbnjdsjusndfjsfsfds
dfjdnhfdjnfdnfdjnbndfjkdnfdnfdjnfd product: cereal, price: $3.50. tax: $0.13 hjnubdfjdfdfdfds..... etc
dfjdnhfdjnfdnfdjnbndfjkdnfdnfdjnfd product: cereal, price: $3.50. tax: $0.13 hjnubdfjdfdfdfds..... etc
yeah..... basically, i want to get the values next to "product", "price" and "tax" without including literally the words product, price, tax. In my output. I can't actually go line by line taking out a specific string, because the pattern could be just about anywhere within the file. I am unsure what syntax or methods to use, i get the logic, and i can easily output the file itself, but i am just not sure how to manipulate what i have.
I have tried stringtokenizer, stringsplit, if statements, and for loop with delimiter, but nothing seems to be working.
If you want little bit of my code of what i have, of what actually works, it would be this.
Code:
import java.io.*;
public static void main(String[] args) {
//open the txt file
bufferedreader in = new bufferedreader(new filereader(store.txt);
string line;
string product;
// read the txt file
while((line = in.readLine()) != null) {
}
System.out.print(line);
}