< prev index next >

src/java.base/share/classes/sun/security/util/HexDumpEncoder.java

Print this page

        

*** 51,61 **** public class HexDumpEncoder { private int offset; private int thisLineLength; private int currentByte; ! private byte thisLine[] = new byte[16]; static void hexDigit(PrintStream p, byte x) { char c; c = (char) ((x >> 4) & 0xf); --- 51,61 ---- public class HexDumpEncoder { private int offset; private int thisLineLength; private int currentByte; ! private byte[] thisLine = new byte[16]; static void hexDigit(PrintStream p, byte x) { char c; c = (char) ((x >> 4) & 0xf);
*** 91,101 **** pStream.print(": "); currentByte = 0; thisLineLength = len; } ! protected void encodeAtom(OutputStream o, byte buf[], int off, int len) throws IOException { thisLine[currentByte] = buf[off]; hexDigit(pStream, buf[off]); pStream.print(" "); currentByte++; if (currentByte == 8) --- 91,101 ---- pStream.print(": "); currentByte = 0; thisLineLength = len; } ! protected void encodeAtom(OutputStream o, byte[] buf, int off, int len) throws IOException { thisLine[currentByte] = buf[off]; hexDigit(pStream, buf[off]); pStream.print(" "); currentByte++; if (currentByte == 8)
*** 127,137 **** /** * This method works around the bizarre semantics of BufferedInputStream's * read method. */ ! protected int readFully(InputStream in, byte buffer[]) throws java.io.IOException { for (int i = 0; i < buffer.length; i++) { int q = in.read(); if (q == -1) return i; --- 127,137 ---- /** * This method works around the bizarre semantics of BufferedInputStream's * read method. */ ! protected int readFully(InputStream in, byte[] buffer) throws java.io.IOException { for (int i = 0; i < buffer.length; i++) { int q = in.read(); if (q == -1) return i;
*** 149,159 **** public void encode(InputStream inStream, OutputStream outStream) throws IOException { int j; int numBytes; ! byte tmpbuffer[] = new byte[bytesPerLine()]; encodeBufferPrefix(outStream); while (true) { numBytes = readFully(inStream, tmpbuffer); --- 149,159 ---- public void encode(InputStream inStream, OutputStream outStream) throws IOException { int j; int numBytes; ! byte[] tmpbuffer = new byte[bytesPerLine()]; encodeBufferPrefix(outStream); while (true) { numBytes = readFully(inStream, tmpbuffer);
*** 179,189 **** /** * A 'streamless' version of encode that simply takes a buffer of * bytes and returns a string containing the encoded buffer. */ ! public String encode(byte aBuffer[]) { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer); String retVal = null; try { encode(inStream, outStream); --- 179,189 ---- /** * A 'streamless' version of encode that simply takes a buffer of * bytes and returns a string containing the encoded buffer. */ ! public String encode(byte[] aBuffer) { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer); String retVal = null; try { encode(inStream, outStream);
*** 262,272 **** public void encodeBuffer(InputStream inStream, OutputStream outStream) throws IOException { int j; int numBytes; ! byte tmpbuffer[] = new byte[bytesPerLine()]; encodeBufferPrefix(outStream); while (true) { numBytes = readFully(inStream, tmpbuffer); --- 262,272 ---- public void encodeBuffer(InputStream inStream, OutputStream outStream) throws IOException { int j; int numBytes; ! byte[] tmpbuffer = new byte[bytesPerLine()]; encodeBufferPrefix(outStream); while (true) { numBytes = readFully(inStream, tmpbuffer);
*** 290,311 **** /** * Encode the buffer in <i>aBuffer</i> and write the encoded * result to the OutputStream <i>aStream</i>. */ ! public void encodeBuffer(byte aBuffer[], OutputStream aStream) throws IOException { ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer); encodeBuffer(inStream, aStream); } /** * A 'streamless' version of encode that simply takes a buffer of * bytes and returns a string containing the encoded buffer. */ ! public String encodeBuffer(byte aBuffer[]) { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer); try { encodeBuffer(inStream, outStream); } catch (Exception IOException) { --- 290,311 ---- /** * Encode the buffer in <i>aBuffer</i> and write the encoded * result to the OutputStream <i>aStream</i>. */ ! public void encodeBuffer(byte[] aBuffer, OutputStream aStream) throws IOException { ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer); encodeBuffer(inStream, aStream); } /** * A 'streamless' version of encode that simply takes a buffer of * bytes and returns a string containing the encoded buffer. */ ! public String encodeBuffer(byte[] aBuffer) { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer); try { encodeBuffer(inStream, outStream); } catch (Exception IOException) {
< prev index next >