I'm trying to search a file for a specific
string that has been entered from a text field, find it and then display the first four characters from the line that it is in.....
here is the code that I have now....
if(e1.getSource()==checkButton){
String SrNo;
SrNo = String.valueOf(SerNo.getText());
try {
BufferedReader in = new BufferedReader(new FileReader("wavail0.txt"));
String str;
while ((str = in.readLine()) != null) {
if (str.indexOf(SrNo) >= 0) {
Quantity.setText("this works");
}
}
in.close();
} catch (IOException e) {
System.out.println("no it didn't work");
}
}
now this will read the line in...I just need to make it so it will show the first four characters in a textfield also.
Any and all suggestion would be great!!