propagate from branch 'i2p.i2p.zzz.test3' (head d4461db52b7de97b89dafa6d6a2b18d9dc075b38)
to branch 'i2p.i2p' (head 5529edcb3dd730aa750302bb4267116c56c354da)
This commit is contained in:
@ -323,7 +323,7 @@ private static long bytesToLong(byte[] b) {
|
||||
if(null == extensions || extensions.isEmpty())
|
||||
return "";
|
||||
|
||||
StringBuffer result = new StringBuffer();
|
||||
StringBuilder result = new StringBuilder();
|
||||
List<String> tempList;
|
||||
boolean first = true;
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class CPUID {
|
||||
private static String getCPUVendorID()
|
||||
{
|
||||
CPUIDResult c = doCPUID(0);
|
||||
StringBuffer sb= new StringBuffer(13);
|
||||
StringBuilder sb= new StringBuilder(13);
|
||||
sb.append((char)( c.EBX & 0xFF));
|
||||
sb.append((char)((c.EBX >> 8) & 0xFF));
|
||||
sb.append((char)((c.EBX >> 16) & 0xFF));
|
||||
|
@ -124,7 +124,7 @@ public class PetName {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(256);
|
||||
StringBuilder buf = new StringBuilder(256);
|
||||
if (_name != null) buf.append(_name.trim());
|
||||
buf.append(':');
|
||||
if (_network != null) buf.append(_network.trim());
|
||||
|
@ -130,7 +130,7 @@ public class ElGamalEngine {
|
||||
System.arraycopy(dbytes, 0, out, (dbytes.length < 257 ? 514 - dbytes.length : 257),
|
||||
(dbytes.length > 257 ? 257 : dbytes.length));
|
||||
/*
|
||||
StringBuffer buf = new StringBuffer(1024);
|
||||
StringBuilder buf = new StringBuilder(1024);
|
||||
buf.append("Timing\n");
|
||||
buf.append("0-1: ").append(t1 - t0).append('\n');
|
||||
buf.append("1-2: ").append(t2 - t1).append('\n');
|
||||
|
@ -179,7 +179,7 @@ public class SHA1Test {
|
||||
}
|
||||
|
||||
private static final String toHex(final byte[] bytes) {
|
||||
StringBuffer buf = new StringBuffer(bytes.length * 2);
|
||||
StringBuilder buf = new StringBuilder(bytes.length * 2);
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
if ((i & 3) == 0 && i != 0)
|
||||
buf.append(' ');
|
||||
|
@ -452,12 +452,12 @@ public class TransientSessionKeyManager extends SessionKeyManager {
|
||||
int removed = 0;
|
||||
int remaining = 0;
|
||||
long now = _context.clock().now();
|
||||
StringBuffer buf = null;
|
||||
StringBuffer bufSummary = null;
|
||||
StringBuilder buf = null;
|
||||
StringBuilder bufSummary = null;
|
||||
if (_log.shouldLog(Log.DEBUG)) {
|
||||
buf = new StringBuffer(128);
|
||||
buf = new StringBuilder(128);
|
||||
buf.append("Expiring inbound: ");
|
||||
bufSummary = new StringBuffer(1024);
|
||||
bufSummary = new StringBuilder(1024);
|
||||
}
|
||||
synchronized (_inboundTagSets) {
|
||||
for (Iterator<SessionTag> iter = _inboundTagSets.keySet().iterator(); iter.hasNext();) {
|
||||
@ -500,7 +500,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
|
||||
}
|
||||
|
||||
public String renderStatusHTML() {
|
||||
StringBuffer buf = new StringBuffer(1024);
|
||||
StringBuilder buf = new StringBuilder(1024);
|
||||
buf.append("<h2>Inbound sessions</h2>");
|
||||
buf.append("<table border=\"1\">");
|
||||
Set<TagSet> inbound = getInboundTagSets();
|
||||
|
@ -255,16 +255,16 @@ D8usM7Dxp5yrDrCYZ5AIijc=
|
||||
}
|
||||
|
||||
private static final String sanitize(String versionString) {
|
||||
StringBuffer versionStringBuffer = new StringBuffer(versionString);
|
||||
StringBuilder versionStringBuilder = new StringBuilder(versionString);
|
||||
|
||||
for (int i = 0; i < versionStringBuffer.length(); i++) {
|
||||
if (VALID_VERSION_CHARS.indexOf(versionStringBuffer.charAt(i)) == -1) {
|
||||
versionStringBuffer.deleteCharAt(i);
|
||||
for (int i = 0; i < versionStringBuilder.length(); i++) {
|
||||
if (VALID_VERSION_CHARS.indexOf(versionStringBuilder.charAt(i)) == -1) {
|
||||
versionStringBuilder.deleteCharAt(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
return versionStringBuffer.toString();
|
||||
return versionStringBuilder.toString();
|
||||
}
|
||||
|
||||
private static final void showUsageCLI() {
|
||||
@ -328,7 +328,7 @@ D8usM7Dxp5yrDrCYZ5AIijc=
|
||||
* delimited by CR LF line breaks.
|
||||
*/
|
||||
public String getTrustedKeysString() {
|
||||
StringBuffer buf = new StringBuffer(1024);
|
||||
StringBuilder buf = new StringBuilder(1024);
|
||||
for (int i = 0; i < _trustedKeys.size(); i++) {
|
||||
// If something already buffered, first add line break.
|
||||
if (buf.length() > 0) buf.append("\r\n");
|
||||
|
@ -73,7 +73,7 @@ public class Address extends DataStructureImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(64);
|
||||
StringBuilder buf = new StringBuilder(64);
|
||||
buf.append("[Address: ");
|
||||
buf.append("\n\tHostname: ").append(getHostname());
|
||||
buf.append("\n\tDestination: ").append(getDestination());
|
||||
|
@ -137,7 +137,7 @@ public class Base32 {
|
||||
}
|
||||
|
||||
public static String encode(byte[] source) {
|
||||
StringBuffer buf = new StringBuffer((source.length + 7) * 8 / 5);
|
||||
StringBuilder buf = new StringBuilder((source.length + 7) * 8 / 5);
|
||||
encodeBytes(source, buf);
|
||||
return buf.toString();
|
||||
}
|
||||
@ -149,7 +149,7 @@ public class Base32 {
|
||||
*
|
||||
* @param source The data to convert
|
||||
*/
|
||||
private static void encodeBytes(byte[] source, StringBuffer out) {
|
||||
private static void encodeBytes(byte[] source, StringBuilder out) {
|
||||
int usedbits = 0;
|
||||
for (int i = 0; i < source.length; ) {
|
||||
int fivebits;
|
||||
|
@ -330,7 +330,7 @@ public class Base64 {
|
||||
} // end switch
|
||||
} // end encode3to4
|
||||
|
||||
private static void encode3to4(byte[] source, int srcOffset, int numSigBytes, StringBuffer buf, byte alpha[]) {
|
||||
private static void encode3to4(byte[] source, int srcOffset, int numSigBytes, StringBuilder buf, byte alpha[]) {
|
||||
// 1 2 3
|
||||
// 01234567890123456789012345678901 Bit position
|
||||
// --------000000001111111122222222 Array position from threeBytes
|
||||
@ -394,7 +394,7 @@ public class Base64 {
|
||||
private static String safeEncode(byte[] source, int off, int len, boolean useStandardAlphabet) {
|
||||
if (len + off > source.length)
|
||||
throw new ArrayIndexOutOfBoundsException("Trying to encode too much! source.len=" + source.length + " off=" + off + " len=" + len);
|
||||
StringBuffer buf = new StringBuffer(len * 4 / 3);
|
||||
StringBuilder buf = new StringBuilder(len * 4 / 3);
|
||||
if (useStandardAlphabet)
|
||||
encodeBytes(source, off, len, false, buf, ALPHABET);
|
||||
else
|
||||
@ -446,7 +446,7 @@ public class Base64 {
|
||||
******/
|
||||
|
||||
private static String encodeBytes(byte[] source, int off, int len, boolean breakLines) {
|
||||
StringBuffer buf = new StringBuffer( (len*4)/3 );
|
||||
StringBuilder buf = new StringBuilder( (len*4)/3 );
|
||||
encodeBytes(source, off, len, breakLines, buf, ALPHABET);
|
||||
return buf.toString();
|
||||
}
|
||||
@ -460,7 +460,7 @@ public class Base64 {
|
||||
* @param breakLines Break lines at 80 characters or less.
|
||||
* @since 1.4
|
||||
*/
|
||||
private static void encodeBytes(byte[] source, int off, int len, boolean breakLines, StringBuffer out, byte alpha[]) {
|
||||
private static void encodeBytes(byte[] source, int off, int len, boolean breakLines, StringBuilder out, byte alpha[]) {
|
||||
//int len43 = len * 4 / 3;
|
||||
//byte[] outBuff = new byte[(len43) // Main 4:3
|
||||
// + ((len % 3) > 0 ? 4 : 0) // Account for padding
|
||||
|
@ -149,7 +149,7 @@ public class Certificate extends DataStructureImpl {
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(64);
|
||||
StringBuilder buf = new StringBuilder(64);
|
||||
buf.append("[Certificate: type: ");
|
||||
if (getCertificateType() == CERTIFICATE_TYPE_NULL)
|
||||
buf.append("Null certificate");
|
||||
|
@ -196,7 +196,7 @@ public class DataHelper {
|
||||
*
|
||||
*/
|
||||
public static String toString(Properties options) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
if (options != null) {
|
||||
for (Iterator iter = options.keySet().iterator(); iter.hasNext();) {
|
||||
String key = (String) iter.next();
|
||||
@ -273,7 +273,7 @@ public class DataHelper {
|
||||
*
|
||||
*/
|
||||
public static String toString(Collection col) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
if (col != null) {
|
||||
for (Iterator iter = col.iterator(); iter.hasNext();) {
|
||||
Object o = iter.next();
|
||||
@ -296,17 +296,17 @@ public class DataHelper {
|
||||
|
||||
public static String toString(byte buf[], int len) {
|
||||
if (buf == null) buf = EMPTY_BUFFER;
|
||||
StringBuffer out = new StringBuffer();
|
||||
StringBuilder out = new StringBuilder();
|
||||
if (len > buf.length) {
|
||||
for (int i = 0; i < len - buf.length; i++)
|
||||
out.append("00");
|
||||
}
|
||||
for (int i = 0; i < buf.length && i < len; i++) {
|
||||
StringBuffer temp = new StringBuffer(Integer.toHexString(buf[i]));
|
||||
StringBuilder temp = new StringBuilder(Integer.toHexString(buf[i]));
|
||||
while (temp.length() < 2) {
|
||||
temp.insert(0, '0');
|
||||
}
|
||||
temp = new StringBuffer(temp.substring(temp.length() - 2));
|
||||
temp = new StringBuilder(temp.substring(temp.length() - 2));
|
||||
out.append(temp.toString());
|
||||
}
|
||||
return out.toString();
|
||||
@ -775,19 +775,27 @@ public class DataHelper {
|
||||
/**
|
||||
* Read a newline delimited line from the stream, returning the line (without
|
||||
* the newline), or null if EOF reached before the newline was found
|
||||
* Warning - strips \n but not \r
|
||||
*/
|
||||
public static String readLine(InputStream in) throws IOException { return readLine(in, (Sha256Standalone)null); }
|
||||
/** update the hash along the way */
|
||||
|
||||
/**
|
||||
* update the hash along the way
|
||||
* Warning - strips \n but not \r
|
||||
*/
|
||||
public static String readLine(InputStream in, Sha256Standalone hash) throws IOException {
|
||||
StringBuffer buf = new StringBuffer(128);
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
boolean ok = readLine(in, buf, hash);
|
||||
if (ok)
|
||||
return buf.toString();
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read in a line, placing it into the buffer (excluding the newline).
|
||||
* Warning - strips \n but not \r
|
||||
* @deprecated use StringBuilder version
|
||||
*
|
||||
* @return true if the line was read, false if eof was reached before a
|
||||
* newline was found
|
||||
@ -795,7 +803,12 @@ public class DataHelper {
|
||||
public static boolean readLine(InputStream in, StringBuffer buf) throws IOException {
|
||||
return readLine(in, buf, null);
|
||||
}
|
||||
/** update the hash along the way */
|
||||
|
||||
/**
|
||||
* update the hash along the way
|
||||
* Warning - strips \n but not \r
|
||||
* @deprecated use StringBuilder version
|
||||
*/
|
||||
public static boolean readLine(InputStream in, StringBuffer buf, Sha256Standalone hash) throws IOException {
|
||||
int c = -1;
|
||||
while ( (c = in.read()) != -1) {
|
||||
@ -810,6 +823,32 @@ public class DataHelper {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read in a line, placing it into the buffer (excluding the newline).
|
||||
* Warning - strips \n but not \r
|
||||
*
|
||||
* @return true if the line was read, false if eof was reached before a
|
||||
* newline was found
|
||||
*/
|
||||
public static boolean readLine(InputStream in, StringBuilder buf) throws IOException {
|
||||
return readLine(in, buf, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* update the hash along the way
|
||||
* Warning - strips \n but not \r
|
||||
*/
|
||||
public static boolean readLine(InputStream in, StringBuilder buf, Sha256Standalone hash) throws IOException {
|
||||
int c = -1;
|
||||
while ( (c = in.read()) != -1) {
|
||||
if (hash != null) hash.update((byte)c);
|
||||
if (c == '\n')
|
||||
break;
|
||||
buf.append((char)c);
|
||||
}
|
||||
return c != -1;
|
||||
}
|
||||
|
||||
public static void write(OutputStream out, byte data[], Sha256Standalone hash) throws IOException {
|
||||
hash.update(data);
|
||||
out.write(data);
|
||||
|
@ -145,7 +145,7 @@ public class Destination extends DataStructureImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(128);
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
buf.append("[Destination: ");
|
||||
buf.append("\n\tHash: ").append(calculateHash().toBase64());
|
||||
buf.append("\n\tPublic Key: ").append(getPublicKey());
|
||||
|
@ -104,7 +104,7 @@ public class Hash extends DataStructureImpl {
|
||||
}
|
||||
if (_log.shouldLog(Log.DEBUG)) {
|
||||
// explicit buffer, since the compiler can't guess how long it'll be
|
||||
StringBuffer buf = new StringBuffer(128);
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
buf.append("miss [").append(cached).append("] from ");
|
||||
buf.append(DataHelper.toHexString(getData())).append(" to ");
|
||||
buf.append(DataHelper.toHexString(key.getData()));
|
||||
@ -113,7 +113,7 @@ public class Hash extends DataStructureImpl {
|
||||
} else {
|
||||
if (_log.shouldLog(Log.DEBUG)) {
|
||||
// explicit buffer, since the compiler can't guess how long it'll be
|
||||
StringBuffer buf = new StringBuffer(128);
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
buf.append("hit from ");
|
||||
buf.append(DataHelper.toHexString(getData())).append(" to ");
|
||||
buf.append(DataHelper.toHexString(key.getData()));
|
||||
@ -155,7 +155,7 @@ public class Hash extends DataStructureImpl {
|
||||
@Override
|
||||
public String toString() {
|
||||
if (_stringified == null) {
|
||||
StringBuffer buf = new StringBuffer(64);
|
||||
StringBuilder buf = new StringBuilder(64);
|
||||
buf.append("[Hash: ");
|
||||
if (_data == null) {
|
||||
buf.append("null hash");
|
||||
|
@ -147,7 +147,7 @@ public class Lease extends DataStructureImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(128);
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
buf.append("[Lease: ");
|
||||
buf.append("\n\tEnd Date: ").append(getEndDate());
|
||||
buf.append("\n\tGateway: ").append(getGateway());
|
||||
|
@ -355,7 +355,7 @@ public class LeaseSet extends DataStructureImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(128);
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
buf.append("[LeaseSet: ");
|
||||
buf.append("\n\tDestination: ").append(getDestination());
|
||||
buf.append("\n\tEncryptionKey: ").append(getEncryptionKey());
|
||||
|
@ -108,7 +108,7 @@ public class Payload extends DataStructureImpl {
|
||||
@Override
|
||||
public String toString() {
|
||||
if (true) return "[Payload]";
|
||||
StringBuffer buf = new StringBuffer(128);
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
buf.append("[Payload: ");
|
||||
if (getUnencryptedData() != null)
|
||||
buf.append("\n\tData: ").append(DataHelper.toString(getUnencryptedData(), 16));
|
||||
|
@ -77,7 +77,7 @@ public class PrivateKey extends DataStructureImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(64);
|
||||
StringBuilder buf = new StringBuilder(64);
|
||||
buf.append("[PrivateKey: ");
|
||||
if (_data == null) {
|
||||
buf.append("null key");
|
||||
|
@ -263,7 +263,7 @@ public class PrivateKeyFile {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer s = new StringBuffer(128);
|
||||
StringBuilder s = new StringBuilder(128);
|
||||
s.append("Dest: ");
|
||||
s.append(this.dest != null ? this.dest.toBase64() : "null");
|
||||
s.append("\nContains: ");
|
||||
|
@ -79,7 +79,7 @@ public class PublicKey extends DataStructureImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(64);
|
||||
StringBuilder buf = new StringBuilder(64);
|
||||
buf.append("[PublicKey: ");
|
||||
if (_data == null) {
|
||||
buf.append("null key");
|
||||
|
@ -138,7 +138,7 @@ public class RouterAddress extends DataStructureImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(64);
|
||||
StringBuilder buf = new StringBuilder(64);
|
||||
buf.append("[RouterAddress: ");
|
||||
buf.append("\n\tTransportStyle: ").append(getTransportStyle());
|
||||
buf.append("\n\tCost: ").append(getCost());
|
||||
|
@ -109,7 +109,7 @@ public class RouterIdentity extends DataStructureImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(64);
|
||||
StringBuilder buf = new StringBuilder(64);
|
||||
buf.append("[RouterIdentity: ");
|
||||
buf.append("\n\tHash: ").append(getHash().toBase64());
|
||||
buf.append("\n\tCertificate: ").append(getCertificate());
|
||||
|
@ -382,7 +382,7 @@ public class RouterInfo extends DataStructureImpl {
|
||||
} else if ((idx = caps.indexOf(cap)) == -1) {
|
||||
return;
|
||||
} else {
|
||||
StringBuffer buf = new StringBuffer(caps);
|
||||
StringBuilder buf = new StringBuilder(caps);
|
||||
while ( (idx = buf.indexOf(""+cap)) != -1)
|
||||
buf.deleteCharAt(idx);
|
||||
_options.setProperty(PROP_CAPABILITIES, buf.toString());
|
||||
@ -555,7 +555,7 @@ public class RouterInfo extends DataStructureImpl {
|
||||
@Override
|
||||
public String toString() {
|
||||
if (_stringified != null) return _stringified;
|
||||
StringBuffer buf = new StringBuffer(5*1024);
|
||||
StringBuilder buf = new StringBuilder(5*1024);
|
||||
buf.append("[RouterInfo: ");
|
||||
buf.append("\n\tIdentity: ").append(getIdentity());
|
||||
buf.append("\n\tSignature: ").append(getSignature());
|
||||
|
@ -84,7 +84,7 @@ public class SessionKey extends DataStructureImpl {
|
||||
@Override
|
||||
public String toString() {
|
||||
if (true) return super.toString();
|
||||
StringBuffer buf = new StringBuffer(64);
|
||||
StringBuilder buf = new StringBuilder(64);
|
||||
buf.append("[SessionKey: ");
|
||||
if (_data == null) {
|
||||
buf.append("null key");
|
||||
|
@ -69,7 +69,7 @@ public class Signature extends DataStructureImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(64);
|
||||
StringBuilder buf = new StringBuilder(64);
|
||||
buf.append("[Signature: ");
|
||||
if (_data == null) {
|
||||
buf.append("null signature");
|
||||
|
@ -75,7 +75,7 @@ public class SigningPrivateKey extends DataStructureImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(64);
|
||||
StringBuilder buf = new StringBuilder(64);
|
||||
buf.append("[SigningPrivateKey: ");
|
||||
if (_data == null) {
|
||||
buf.append("null key");
|
||||
|
@ -74,7 +74,7 @@ public class SigningPublicKey extends DataStructureImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(64);
|
||||
StringBuilder buf = new StringBuilder(64);
|
||||
buf.append("[SigningPublicKey: ");
|
||||
if (_data == null) {
|
||||
buf.append("null key");
|
||||
|
@ -155,7 +155,7 @@ public class VerifiedDestination extends Destination {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(128);
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
buf.append(super.toString());
|
||||
buf.append("\n\tVerified Certificate? ").append(verifyCert(true));
|
||||
return buf.toString();
|
||||
|
@ -91,7 +91,7 @@ public class BandwidthLimitsMessage extends I2CPMessageImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("[BandwidthLimitsMessage");
|
||||
buf.append("\n\tIn: ").append(data[0]);
|
||||
buf.append("\n\tOut: ").append(data[1]);
|
||||
|
@ -128,7 +128,7 @@ public class CreateLeaseSetMessage extends I2CPMessageImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("[CreateLeaseSetMessage: ");
|
||||
buf.append("\n\tLeaseSet: ").append(getLeaseSet());
|
||||
buf.append("\n\tSigningPrivateKey: ").append(getSigningPrivateKey());
|
||||
|
@ -84,7 +84,7 @@ public class CreateSessionMessage extends I2CPMessageImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("[CreateSessionMessage: ");
|
||||
buf.append("\n\tConfig: ").append(getSessionConfig());
|
||||
buf.append("]");
|
||||
|
@ -67,7 +67,7 @@ public class DestLookupMessage extends I2CPMessageImpl {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("[DestLookupMessage: ");
|
||||
buf.append("\n\tHash: ").append(_hash);
|
||||
buf.append("]");
|
||||
|
@ -69,7 +69,7 @@ public class DestReplyMessage extends I2CPMessageImpl {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("[DestReplyMessage: ");
|
||||
buf.append("\n\tDestination: ").append(_dest);
|
||||
buf.append("]");
|
||||
|
@ -80,7 +80,7 @@ public class DestroySessionMessage extends I2CPMessageImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("[DestroySessionMessage: ");
|
||||
buf.append("\n\tSessionId: ").append(getSessionId());
|
||||
buf.append("]");
|
||||
|
@ -76,7 +76,7 @@ public class DisconnectMessage extends I2CPMessageImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("[DisconnectMessage: ");
|
||||
buf.append("\n\tReason: ").append(getReason());
|
||||
buf.append("]");
|
||||
|
@ -49,7 +49,7 @@ public class GetBandwidthLimitsMessage extends I2CPMessageImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("[GetBandwidthLimitsMessage]");
|
||||
return buf.toString();
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class GetDateMessage extends I2CPMessageImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("[GetDateMessage]");
|
||||
return buf.toString();
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ public class MessagePayloadMessage extends I2CPMessageImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("[MessagePayloadMessage: ");
|
||||
buf.append("\n\tSessionId: ").append(getSessionId());
|
||||
buf.append("\n\tMessageId: ").append(getMessageId());
|
||||
|
@ -168,7 +168,7 @@ public class MessageStatusMessage extends I2CPMessageImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("[MessageStatusMessage: ");
|
||||
buf.append("\n\tSessionId: ").append(getSessionId());
|
||||
buf.append("\n\tNonce: ").append(getNonce());
|
||||
|
@ -102,7 +102,7 @@ public class ReceiveMessageBeginMessage extends I2CPMessageImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("[ReceiveMessageBeginMessage: ");
|
||||
buf.append("\n\tSessionId: ").append(getSessionId());
|
||||
buf.append("\n\tMessageId: ").append(getMessageId());
|
||||
|
@ -86,7 +86,7 @@ public class ReceiveMessageEndMessage extends I2CPMessageImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("[ReceiveMessageEndMessage: ");
|
||||
buf.append("\n\tSessionId: ").append(getSessionId());
|
||||
buf.append("\n\tMessageId: ").append(getMessageId());
|
||||
|
@ -93,7 +93,7 @@ public class ReconfigureSessionMessage extends I2CPMessageImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("[ReconfigureSessionMessage: ");
|
||||
buf.append("\n\tSessionId: ").append(getSessionId());
|
||||
buf.append("\n\tSessionConfig: ").append(getSessionConfig());
|
||||
|
@ -123,7 +123,7 @@ public class ReportAbuseMessage extends I2CPMessageImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("[ReportAbuseMessage: ");
|
||||
buf.append("\n\tSessionID: ").append(getSessionId());
|
||||
buf.append("\n\tSeverity: ").append(getSeverity());
|
||||
|
@ -143,7 +143,7 @@ public class RequestLeaseSetMessage extends I2CPMessageImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("[RequestLeaseMessage: ");
|
||||
buf.append("\n\tSessionId: ").append(getSessionId());
|
||||
buf.append("\n\tTunnels:");
|
||||
|
@ -104,7 +104,7 @@ public class SendMessageExpiresMessage extends SendMessageMessage {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("[SendMessageMessage: ");
|
||||
buf.append("\n\tSessionId: ").append(getSessionId());
|
||||
buf.append("\n\tNonce: ").append(getNonce());
|
||||
|
@ -149,7 +149,7 @@ public class SendMessageMessage extends I2CPMessageImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("[SendMessageMessage: ");
|
||||
buf.append("\n\tSessionId: ").append(getSessionId());
|
||||
buf.append("\n\tNonce: ").append(getNonce());
|
||||
|
@ -218,7 +218,7 @@ public class SessionConfig extends DataStructureImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer("[SessionConfig: ");
|
||||
StringBuilder buf = new StringBuilder("[SessionConfig: ");
|
||||
buf.append("\n\tDestination: ").append(getDestination());
|
||||
buf.append("\n\tSignature: ").append(getSignature());
|
||||
buf.append("\n\tCreation Date: ").append(getCreationDate());
|
||||
|
@ -96,7 +96,7 @@ public class SessionStatusMessage extends I2CPMessageImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("[SessionStatusMessage: ");
|
||||
buf.append("\n\tSessionId: ").append(getSessionId());
|
||||
buf.append("\n\tStatus: ").append(getStatus());
|
||||
|
@ -79,7 +79,7 @@ public class SetDateMessage extends I2CPMessageImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("[SetDateMessage");
|
||||
buf.append("\n\tDate: ").append(getDate());
|
||||
buf.append("]");
|
||||
|
@ -9,13 +9,13 @@ class PersistenceHelper {
|
||||
private final static Log _log = new Log(PersistenceHelper.class);
|
||||
private final static String NL = System.getProperty("line.separator");
|
||||
|
||||
public final static void add(StringBuffer buf, String prefix, String name, String description, double value) {
|
||||
public final static void add(StringBuilder buf, String prefix, String name, String description, double value) {
|
||||
buf.append("# ").append(prefix).append(name).append(NL);
|
||||
buf.append("# ").append(description).append(NL);
|
||||
buf.append(prefix).append(name).append('=').append(value).append(NL).append(NL);
|
||||
}
|
||||
|
||||
public final static void add(StringBuffer buf, String prefix, String name, String description, long value) {
|
||||
public final static void add(StringBuilder buf, String prefix, String name, String description, long value) {
|
||||
buf.append("# ").append(prefix).append(name).append(NL);
|
||||
buf.append("# ").append(description).append(NL);
|
||||
buf.append(prefix).append(name).append('=').append(value).append(NL).append(NL);
|
||||
|
@ -363,7 +363,7 @@ public class Rate {
|
||||
return 0.0D;
|
||||
}
|
||||
|
||||
public void store(String prefix, StringBuffer buf) throws IOException {
|
||||
public void store(String prefix, StringBuilder buf) throws IOException {
|
||||
PersistenceHelper.add(buf, prefix, ".period", "Number of milliseconds in the period", _period);
|
||||
PersistenceHelper.add(buf, prefix, ".creationDate",
|
||||
"When was this rate created? (milliseconds since the epoch, GMT)", _creationDate);
|
||||
@ -454,7 +454,7 @@ public class Rate {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(2048);
|
||||
StringBuilder buf = new StringBuilder(2048);
|
||||
buf.append("\n\t total value: ").append(getLastTotalValue());
|
||||
buf.append("\n\t highest total value: ").append(getExtremeTotalValue());
|
||||
buf.append("\n\t lifetime total value: ").append(getLifetimeTotalValue());
|
||||
@ -494,7 +494,7 @@ public class Rate {
|
||||
rate.addData(i * 100, 20);
|
||||
}
|
||||
rate.coalesce();
|
||||
StringBuffer buf = new StringBuffer(1024);
|
||||
StringBuilder buf = new StringBuilder(1024);
|
||||
try {
|
||||
rate.store("rate.test", buf);
|
||||
byte data[] = buf.toString().getBytes();
|
||||
|
@ -93,7 +93,7 @@ public class RateStat {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(4096);
|
||||
StringBuilder buf = new StringBuilder(4096);
|
||||
buf.append(getGroupName()).append('.').append(getName()).append(": ").append(getDescription()).append('\n');
|
||||
long periods[] = getPeriods();
|
||||
Arrays.sort(periods);
|
||||
@ -121,7 +121,7 @@ public class RateStat {
|
||||
}
|
||||
|
||||
public void store(OutputStream out, String prefix) throws IOException {
|
||||
StringBuffer buf = new StringBuffer(1024);
|
||||
StringBuilder buf = new StringBuilder(1024);
|
||||
buf.append(NL);
|
||||
buf.append("################################################################################").append(NL);
|
||||
buf.append("# Rate: ").append(_groupName).append(": ").append(_statName).append(NL);
|
||||
|
@ -14,13 +14,13 @@ public class SimpleStatDumper {
|
||||
public static void dumpStats(I2PAppContext context, int logLevel) {
|
||||
if (!_log.shouldLog(logLevel)) return;
|
||||
|
||||
StringBuffer buf = new StringBuffer(4 * 1024);
|
||||
StringBuilder buf = new StringBuilder(4 * 1024);
|
||||
dumpFrequencies(context, buf);
|
||||
dumpRates(context, buf);
|
||||
_log.log(logLevel, buf.toString());
|
||||
}
|
||||
|
||||
private static void dumpFrequencies(I2PAppContext ctx, StringBuffer buf) {
|
||||
private static void dumpFrequencies(I2PAppContext ctx, StringBuilder buf) {
|
||||
Set frequencies = new TreeSet(ctx.statManager().getFrequencyNames());
|
||||
for (Iterator iter = frequencies.iterator(); iter.hasNext();) {
|
||||
String name = (String) iter.next();
|
||||
@ -40,7 +40,7 @@ public class SimpleStatDumper {
|
||||
}
|
||||
}
|
||||
|
||||
private static void dumpRates(I2PAppContext ctx, StringBuffer buf) {
|
||||
private static void dumpRates(I2PAppContext ctx, StringBuilder buf) {
|
||||
Set rates = new TreeSet(ctx.statManager().getRateNames());
|
||||
for (Iterator iter = rates.iterator(); iter.hasNext();) {
|
||||
String name = (String) iter.next();
|
||||
@ -59,7 +59,7 @@ public class SimpleStatDumper {
|
||||
}
|
||||
}
|
||||
|
||||
static void dumpRate(Rate curRate, StringBuffer buf) {
|
||||
static void dumpRate(Rate curRate, StringBuilder buf) {
|
||||
buf.append(curRate.toString());
|
||||
}
|
||||
}
|
@ -197,7 +197,7 @@ public class Timestamper implements Runnable {
|
||||
} else {
|
||||
if (Math.abs(delta - expectedDelta) > MAX_VARIANCE) {
|
||||
if (_log.shouldLog(Log.ERROR)) {
|
||||
StringBuffer err = new StringBuffer(96);
|
||||
StringBuilder err = new StringBuilder(96);
|
||||
err.append("SNTP client variance exceeded at query ").append(i);
|
||||
err.append(". expected = ");
|
||||
err.append(expectedDelta);
|
||||
@ -214,7 +214,7 @@ public class Timestamper implements Runnable {
|
||||
}
|
||||
stampTime(now);
|
||||
if (_log.shouldLog(Log.DEBUG)) {
|
||||
StringBuffer buf = new StringBuffer(64);
|
||||
StringBuilder buf = new StringBuilder(64);
|
||||
buf.append("Deltas: ");
|
||||
for (int i = 0; i < found.length; i++)
|
||||
buf.append(found[i]).append(' ');
|
||||
|
@ -218,7 +218,7 @@ public class BufferedRandomSource extends RandomSource {
|
||||
System.out.println("Data: " + data.length + "/" + compressed.length + ": " + toString(data));
|
||||
}
|
||||
private static final String toString(byte data[]) {
|
||||
StringBuffer buf = new StringBuffer(data.length * 9);
|
||||
StringBuilder buf = new StringBuilder(data.length * 9);
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
for (int j = 0; j < 8; j++) {
|
||||
if ((data[i] & (1 << j)) != 0)
|
||||
|
@ -207,7 +207,7 @@ public class EepGet {
|
||||
"01234567890.,_=@#:";
|
||||
private static String sanitize(String name) {
|
||||
name = name.replace('/', '_');
|
||||
StringBuffer buf = new StringBuffer(name);
|
||||
StringBuilder buf = new StringBuilder(name);
|
||||
for (int i = 0; i < name.length(); i++)
|
||||
if (_safeChars.indexOf(buf.charAt(i)) == -1)
|
||||
buf.setCharAt(i, '_');
|
||||
@ -292,7 +292,7 @@ public class EepGet {
|
||||
long now = _context.clock().now();
|
||||
long timeToSend = now - _lastComplete;
|
||||
if (timeToSend > 0) {
|
||||
StringBuffer buf = new StringBuffer(50);
|
||||
StringBuilder buf = new StringBuilder(50);
|
||||
buf.append(" ");
|
||||
if ( bytesRemaining > 0 ) {
|
||||
double pct = ((double)_written + _previousWritten) /
|
||||
@ -353,7 +353,7 @@ public class EepGet {
|
||||
if (_etag != null)
|
||||
System.out.println("== ETag: " + _etag);
|
||||
if (transferred > 0) {
|
||||
StringBuffer buf = new StringBuffer(50);
|
||||
StringBuilder buf = new StringBuilder(50);
|
||||
buf.append("== Transfer rate: ");
|
||||
double kbps = (1000.0d*(double)(transferred)/((double)timeToSend*1024.0d));
|
||||
synchronized (_kbps) {
|
||||
@ -381,7 +381,7 @@ public class EepGet {
|
||||
long timeToSend = _context.clock().now() - _startedOn;
|
||||
System.out.println("== Transfer time: " + DataHelper.formatDuration(timeToSend));
|
||||
double kbps = (timeToSend > 0 ? (1000.0d*(double)(bytesTransferred)/((double)timeToSend*1024.0d)) : 0);
|
||||
StringBuffer buf = new StringBuffer(50);
|
||||
StringBuilder buf = new StringBuilder(50);
|
||||
buf.append("== Transfer rate: ");
|
||||
synchronized (_kbps) {
|
||||
buf.append(_kbps.format(kbps));
|
||||
@ -627,7 +627,7 @@ public class EepGet {
|
||||
|
||||
private void readHeaders() throws IOException {
|
||||
String key = null;
|
||||
StringBuffer buf = new StringBuffer(32);
|
||||
StringBuilder buf = new StringBuilder(32);
|
||||
|
||||
boolean read = DataHelper.readLine(_proxyIn, buf);
|
||||
if (!read) throw new IOException("Unable to read the first line");
|
||||
@ -738,7 +738,7 @@ public class EepGet {
|
||||
}
|
||||
|
||||
private long readChunkLength() throws IOException {
|
||||
StringBuffer buf = new StringBuffer(8);
|
||||
StringBuilder buf = new StringBuilder(8);
|
||||
int nl = 0;
|
||||
while (true) {
|
||||
int cur = _proxyIn.read();
|
||||
@ -893,7 +893,7 @@ public class EepGet {
|
||||
}
|
||||
|
||||
private String getRequest() throws IOException {
|
||||
StringBuffer buf = new StringBuffer(512);
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
boolean post = false;
|
||||
if ( (_postData != null) && (_postData.length() > 0) )
|
||||
post = true;
|
||||
@ -922,7 +922,8 @@ public class EepGet {
|
||||
buf.append("-\r\n");
|
||||
}
|
||||
buf.append("Accept-Encoding: \r\n");
|
||||
buf.append("X-Accept-Encoding: x-i2p-gzip;q=1.0, identity;q=0.5, deflate;q=0, gzip;q=0, *;q=0\r\n");
|
||||
if (_shouldProxy)
|
||||
buf.append("X-Accept-Encoding: x-i2p-gzip;q=1.0, identity;q=0.5, deflate;q=0, gzip;q=0, *;q=0\r\n");
|
||||
if (!_allowCaching) {
|
||||
buf.append("Cache-control: no-cache\r\n");
|
||||
buf.append("Pragma: no-cache\r\n");
|
||||
|
@ -184,7 +184,7 @@ public class EepPost {
|
||||
}
|
||||
|
||||
private String getHeader(boolean isProxy, String path, String host, int port, String separator, long length) {
|
||||
StringBuffer buf = new StringBuffer(512);
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("POST ");
|
||||
if (isProxy) {
|
||||
buf.append("http://").append(host);
|
||||
@ -212,7 +212,7 @@ public class EepPost {
|
||||
return "------------------------" + new java.util.Random().nextLong();
|
||||
byte separator[] = new byte[32]; // 2^-128 chance of this being a problem
|
||||
I2PAppContext.getGlobalContext().random().nextBytes(separator);
|
||||
StringBuffer sep = new StringBuffer(48);
|
||||
StringBuilder sep = new StringBuilder(48);
|
||||
for (int i = 0; i < separator.length; i++)
|
||||
sep.append((char)((int)'a' + (int)(separator[i]&0x0F))).append((char)((int)'a' + (int)((separator[i] >>> 4) & 0x0F)));
|
||||
return sep.toString();
|
||||
|
@ -160,7 +160,7 @@ public class FileUtil {
|
||||
lines.remove(0);
|
||||
}
|
||||
}
|
||||
StringBuffer buf = new StringBuffer(lines.size() * 80);
|
||||
StringBuilder buf = new StringBuilder(lines.size() * 80);
|
||||
for (int i = 0; i < lines.size(); i++)
|
||||
buf.append((String)lines.get(i)).append('\n');
|
||||
return buf.toString();
|
||||
|
@ -546,7 +546,7 @@ public class LogManager {
|
||||
}
|
||||
|
||||
private String createConfig() {
|
||||
StringBuffer buf = new StringBuffer(8*1024);
|
||||
StringBuilder buf = new StringBuilder(8*1024);
|
||||
buf.append(PROP_FORMAT).append('=').append(new String(_format)).append('\n');
|
||||
buf.append(PROP_DATEFORMAT).append('=').append(_dateFormatPattern).append('\n');
|
||||
buf.append(PROP_DISPLAYONSCREEN).append('=').append((_displayOnScreen ? "TRUE" : "FALSE")).append('\n');
|
||||
|
@ -30,7 +30,7 @@ class LogRecordFormatter {
|
||||
int size = 128 + rec.getMessage().length();
|
||||
if (rec.getThrowable() != null)
|
||||
size += 512;
|
||||
StringBuffer buf = new StringBuffer(size);
|
||||
StringBuilder buf = new StringBuilder(size);
|
||||
char format[] = manager.getFormat();
|
||||
for (int i = 0; i < format.length; ++i) {
|
||||
switch (format[i]) {
|
||||
@ -93,7 +93,7 @@ class LogRecordFormatter {
|
||||
}
|
||||
|
||||
private static String toString(String str, int size) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
if (str == null) str = "";
|
||||
if (str.length() > size) str = str.substring(str.length() - size);
|
||||
buf.append(str);
|
||||
|
@ -238,7 +238,7 @@ class LogWriter implements Runnable {
|
||||
|
||||
private static final String replace(String pattern, int num) {
|
||||
char c[] = pattern.toCharArray();
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (int i = 0; i < c.length; i++) {
|
||||
if ( (c[i] != '#') && (c[i] != '@') )
|
||||
buf.append(c[i]);
|
||||
|
@ -233,7 +233,7 @@ public class SimpleTimer {
|
||||
} else {
|
||||
_occurredTime = now;
|
||||
if (_occurredEventCount > 2500) {
|
||||
StringBuffer buf = new StringBuffer(128);
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
buf.append("Too many simpleTimerJobs (").append(_occurredEventCount);
|
||||
buf.append(") in a second!");
|
||||
_log.log(Log.WARN, buf.toString());
|
||||
|
@ -58,7 +58,7 @@ public class SocketTimeout implements SimpleTimer.TimedEvent {
|
||||
private static String ts(long when) { synchronized (_fmt) { return _fmt.format(new Date(when)); } }
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("started on ");
|
||||
buf.append(ts(_startTime));
|
||||
buf.append("idle for ");
|
||||
|
@ -212,7 +212,7 @@ public class BloomSHA1 {
|
||||
}
|
||||
// DEBUG METHODS
|
||||
public static String keyToString(byte[] key) {
|
||||
StringBuffer sb = new StringBuffer().append(key[0]);
|
||||
StringBuilder sb = new StringBuilder().append(key[0]);
|
||||
for (int i = 1; i < key.length; i++) {
|
||||
sb.append(".").append(Integer.toString(key[i], 16));
|
||||
}
|
||||
@ -220,14 +220,14 @@ public class BloomSHA1 {
|
||||
}
|
||||
/** convert 64-bit integer to hex String */
|
||||
public static String ltoh (long i) {
|
||||
StringBuffer sb = new StringBuffer().append("#")
|
||||
StringBuilder sb = new StringBuilder().append("#")
|
||||
.append(Long.toString(i, 16));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/** convert 32-bit integer to String */
|
||||
public static String itoh (int i) {
|
||||
StringBuffer sb = new StringBuffer().append("#")
|
||||
StringBuilder sb = new StringBuilder().append("#")
|
||||
.append(Integer.toString(i, 16));
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -70,12 +70,12 @@ public class HMACSHA256Bench {
|
||||
long maxLong1 = 0;
|
||||
|
||||
byte[] smess = new String("abc").getBytes();
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (int x = 0; x < 2*1024; x++) {
|
||||
buf.append("a");
|
||||
}
|
||||
byte[] mmess = buf.toString().getBytes(); // new String("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq").getBytes();
|
||||
buf = new StringBuffer();
|
||||
buf = new StringBuilder();
|
||||
for (int x = 0; x < 10000; x++) {
|
||||
buf.append("a");
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ public class SHA1HashTest extends TestCase{
|
||||
}
|
||||
|
||||
private final String toHex(final byte[] bytes) {
|
||||
StringBuffer buf = new StringBuffer(bytes.length * 2);
|
||||
StringBuilder buf = new StringBuilder(bytes.length * 2);
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
if ((i & 3) == 0 && i != 0)
|
||||
buf.append(' ');
|
||||
|
@ -57,12 +57,12 @@ public class SHA256Bench {
|
||||
long maxLong1 = 0;
|
||||
|
||||
byte[] smess = new String("abc").getBytes();
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (int x = 0; x < 10*1024; x++) {
|
||||
buf.append("a");
|
||||
}
|
||||
byte[] mmess = buf.toString().getBytes(); // new String("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq").getBytes();
|
||||
buf = new StringBuffer();
|
||||
buf = new StringBuilder();
|
||||
for (int x = 0; x < 1000000; x++) {
|
||||
buf.append("a");
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class RateTest extends TestCase {
|
||||
rate.addData(i * 100, 20);
|
||||
}
|
||||
rate.coalesce();
|
||||
StringBuffer buf = new StringBuffer(1024);
|
||||
StringBuilder buf = new StringBuilder(1024);
|
||||
|
||||
rate.store("rate.test", buf);
|
||||
byte data[] = buf.toString().getBytes();
|
||||
|
Reference in New Issue
Block a user