Java Reference
In-Depth Information
StringBuffer sb = new StringBuffer();
int offset = 0;
int ch;
while ((ch = fis.read()) != -1)
{
if ((offset%16) == 0)
{
writeStr(fos, toHexStr(offset, 8));
fos.write(' ');
}
writeStr(fos, toHexStr(ch, 2));
fos.write(' ');
if (ch < 32 || ch > 127)
sb.append('.');
else
sb.append((char) ch);
if ((++offset%16) == 0)
{
writeStr(fos,
sb.toString()+LINE_SEPARATOR);
sb.setLength(0);
}
}
if (sb.length() != 0)
{
for (int i = 0; i < 16-sb.length(); i++)
writeStr(fos, " ");
writeStr(fos, sb.toString()+LINE_SEPARATOR);
}
}
catch (IOException ioe)
{
System.err.println("I/O
error:
"+ioe.getMessage());
}
}
Search WWH ::




Custom Search