How can you read a certain line from a file without wasting your time processing each line like this:
Like, if I had a list of 5000 words, and I wanted to skip to the 1234th word, how would I do that? I know I could use a counting variable in the above example, but I wouldn't want to keep reading everyline like that untill I got to the right one.Code:try { BufferedReader in = new BufferedReader(new FileReader("infilename")); String str; while ((str = in.readLine()) != null) { process(str); } in.close(); } catch (IOException e) {}


Reply With Quote