Methods Summary |
---|
public boolean | checkError()
return out.checkError();
|
public void | close()
out.close();
|
public void | flush()
out.flush();
|
public void | print(java.lang.Object x)
print(x.toString());
|
public void | print(java.lang.String x)
int length = x.length();
for (int i = 0; i < length; i++) {
write(x.charAt(i));
}
|
public void | print(int x)
print(Integer.toString(x));
|
public final void | printHexInt(int v)
hexString = new String[0x100];
for(int i = 0; i < 256; i++){
hexString[i] = Integer.toHexString(i + 256).substring(1);
}
int a, b, c, d;
a = v>>>24;
b = (v>>>16) & 0xff;
c = (v>>>8) & 0xff;
d = v & 0xff;
print("0x");
if ( a != 0 ){
print(hexString[ a ]);
print(hexString[ b ]);
print(hexString[ c ]);
print(hexString[ d ]);
} else if ( b != 0 ){
print(hexString[ b ]);
print(hexString[ c ]);
print(hexString[ d ]);
} else if ( c != 0 ){
print(hexString[ c ]);
print(hexString[ d ]);
} else {
print(hexString[ d ]);
}
|
void | printSafeString(java.lang.String x)
final int STRING_PURE = 0;
final int STRING_SOME_BAD = 1;
final int STRING_ALL_BAD = 2;
// STRING_PURE means there are no problematic characters.
//
// STRING_SOME_BAD means that we should print out the string
// normally, but escape the uncertain characters.
//
// STRING_ALL_BAD means that we encountered a character that makes
// us believe that this is an encoded string, and we should print
// out everything except letters using escape sequences.
int stringType = STRING_PURE;
int length = x.length();
for (int i = 0; i < length; i++) {
char c = x.charAt(i);
if (c < ' " || c > '~") {
stringType = STRING_ALL_BAD;
break;
}
if (c == '"" || c == '\\" || c == '/") {
stringType = STRING_SOME_BAD;
}
}
write ('"");
if (stringType == STRING_PURE) {
// There were no bad characters whatsoever. Just print it
print(x);
write('"");
return;
}
for (int i = 0; i < length; i++) {
char c = x.charAt(i);
if (Character.isLetterOrDigit(c) && c < 128) {
write(c);
} else if ((stringType != STRING_ALL_BAD)
&& ( c >= (byte)' " ) && ( c <= (byte)'~" )
&& ( c != (byte)'"") && (c != (byte)'\\" )
&& ( c != (byte)'/")) {
// the only dangers between space and ~ are " and \
// We must also be careful about writing */ by accident.
write(c);
} else {
switch ( c ){
case '\\":
print("\\\\");
break;
case '\n":
print("\\n");
break;
case '\r":
print("\\r");
break;
case '\t":
print("\\t");
break;
case '"":
print("\\\"");
break;
case '/":
// we only have a problem if the previous char was an
// asterisk. It looks like we're ending the comment.
if (i > 0 && x.charAt(i - 1) == (byte)'*")
write('\\");
write('/");
break;
default:
int temp = (c & 0xFF) + 01000;
print("\\");
print(Integer.toOctalString(temp).substring(1));
break;
// end of switch
}
}
} // end of for
write('"");
|
public void | println(java.lang.String x)
print(x);
write('\n");
|
public void | println()
write('\n");
|
public void | write(int x)
if (x == '\n") {
out.write(x);
column = 0;
} else if (x == '\t") {
do { out.write(' "); column++;
} while ((column % 4) != 0);
} else {
out.write(x);
column++;
}
|