First of all sorry for my bad english :(blush):
i have a text file and look like this.
username score
aa 70
java 50
aa 40
i want to do list only username: aa on output but i can't do this can you help me ?
Thanks.
Printable View
First of all sorry for my bad english :(blush):
i have a text file and look like this.
username score
aa 70
java 50
aa 40
i want to do list only username: aa on output but i can't do this can you help me ?
Thanks.
its only write single line. i want write to output all starts with "a"Code:ArrayList<String> fields = new ArrayList<String>();
String line;
try {
BufferedReader br = new BufferedReader(new FileReader("scored.txt"));
while ((line = br.readLine()) != null) {
if(line.startsWith("a")){
System.out.println(line);
}
}
br.close();
} catch (Exception e) {//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
sorry my text file have only one starts with "a" :) i forgot edit my text file :(blush):
Thank you so much :(handshake):
My program is working.