java - Reading bytes from a file -
i reading ".264" file using code below.
public static void main (string[] args) throws ioexception { bufferedreader br = null;try { string scurrentline; br = new bufferedreader(new inputstreamreader(new fileinputstream("test.264"),"iso-8859-1")); stringbuffer stringbuffer = new stringbuffer(); while ((scurrentline = br.readline()) != null) { stringbuffer.append(scurrentline); } string tempdec = new string(asciitohex(stringbuffer.tostring())); system.out.println(tempdec); string asciiequivalent = hextoascii(tempdec); bufferedwriter xx = new bufferedwriter(new outputstreamwriter(new fileoutputstream("c:/users/administrator/desktop/yuvplayer-2.3/video dinalized/testret.264"),"iso-8859-1")); xx.write(asciiequivalent); xx.close(); }catch (ioexception e) { e.printstacktrace(); } { try { if (br != null)br.close(); } catch (ioexception ex) { ex.printstacktrace(); } } }
opening input , output file in hex editor show me missing values, e.g. 0d
(see pictures attached).
any solution fix this?
lose inputstreamreader
, bufferedreader
, use fileinputstream
on own.
no character encoding, no line endings, bytes.
javadoc page here, should need.
tip if want read entire file @ once: file.length()
, in
file file = new file("test.264"); byte[] buf = new byte[(int)file.length()]; // use buf in inputstream.read()
Comments
Post a Comment