Hi,

I am working on the SVN sensor. I can get any revision of any file stored in SVN through an OutputStream, which essentially means I get a byte array of contents which I don't know it's text or binary.

Even for text, they can be encoded in ASCII, Unicode, UTF-8, etc. My question is:

(1) Is there a way in Java to tell between binary and text content from a byte array?

(2) If I know that a byte array contains text content, how do I convert them into an array of Strings, each representing one line.

byte[] inputs = ..... BufferedReader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(inputs)));
   String line = reader.readLine();
   while (line != null) {
     System.out.println(line);
     line = reader.readLine();
   }

What I find the above code can only handle ASCII encoded text file successful, the output is messed up with unicode. Any experts?

Thanks.

Cedric

Reply via email to