I am using the new App Engine file api to read in a file from the
blobstore and parse things out from specific lines. Can someone tell
me how I could jump to a specific line in the file without having to
iterate over every line until I find the line number I need?

Here is how I am currently doing it:

                        AppEngineFile file = null;
                        FileService fs = FileServiceFactory.getFileService();

                        file = fs.getBlobFile(new BlobKey(blobKeyString));

                        FileReadChannel readChannel = fs.openReadChannel(file, 
false);

                        BufferedReader reader = new
BufferedReader(Channels.newReader(readChannel, "UTF8"));

                        String line = null;
                        int linePosition = lineNumber;
                        while((line = reader.readLine()) != null){

                                if ((linePosition >= lineNumber) && 
(linePosition < lineNumber +
LINECOUNT)) {
                                        //do stuff with line here
                                }
                                else if(linePosition == lineNumber + LINECOUNT)
                                        break;

                                linePosition++;
                        }

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to