I'm slightly stuck on this problem. I want to search for a particular value, and once it has been found in the txt file, then i would like the whole line in which the value is located to be printed out. The values are stored as follows:
[12, 14] [56, 89] etc
Here is what i've been able to do so far (with struggle) and it still isn't perfect!
import java.io.*; class read2 { public static void main(String [] args) throws IOException { BufferedReader in =new BufferedReader(new FileReader("arrayStrng.txt"));
boolean found = false; int t=in.read(); System.out.println("enter value:"); String s = in.readLine(); int x=Integer.parseInt(s); while(t!=-1)
for(int i=1;(!found); i++) { in.readLine();
if (t== 's')System.out.println(//then display the whole line in which this value is); found = true; } } }
I think I'm on the right lines, but I just can't find the value from the file and print its partnering value (the remaining part of the line).