Percy
Percy

Reputation: 129

How do you read successive lines of linefeed-delimited text using a BlobstoreInputStream?

I would like to read a line of text at a time from the Blobstore using a BlobstoreInputStream and process the text

123,ABC,DEF,GHI,JKL,123,456,789,123\r\n

But the BlobstoreInputStream read methods don't offer the option to read successive chunks of delimited data based on a delimiter (\r\n in this case).

Is there a way to programmatically use one of the available read methods to do this:

public int read() throws java.io.IOException

public int read(byte[] b, int off, int len) throws java.io.IOException

Upvotes: 1

Views: 248

Answers (1)

dko
dko

Reputation: 718

Does the BlobstoreInputStream extend the Stream interface? If it does you could pass it into the constructor of a new Scanner, or a BufferedInputReader class, those each have a ReadLine() method or something similar.

I personally like the Scanner class because the conventional while loop for that is

while(scanner.hasNextLine()){
String s = scanner.NextLine();
....
}

Upvotes: 2

Related Questions