Yeah CornedBee is right. You could use a string StringTokenizer.
The data stored in your text file can be delimited by characters other then spaces if you want by passing in a string to the StringTokenizer as the second arguement. The problem that i found using a StringTokenizer though is that everything is parsed and returned. For instance if your data is set up as such.
customer name: John
book title(s) ordered: 125
order date: 09/11/02
you will get the following.
customer name
John
book title(s) ordered
125
order date
09/11/02
The code that produces the previous output is the following.
Code:
import java.io.*;
import java.util.*;
class Grabber{
public static void main(String[] args){
try{
File f = new File("C://Java/text.txt");
BufferedReader buff = new BufferedReader(new FileReader(f));
while(true){
String x = buff.readLine();
if(x == null) break;
StringTokenizer st = new StringTokenizer(x,":");
while(st.hasMoreTokens()){
System.out.println(st.nextToken());
}
}
}catch(IOException e){System.err.println(e);}
}
}