forked from I2P_Developers/i2p.i2p
Clean up single char indexOf()
This commit is contained in:
@@ -102,12 +102,7 @@ public class Base32 {
|
||||
|
||||
private static byte[] read(InputStream in) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream(64);
|
||||
byte buf[] = new byte[64];
|
||||
while (true) {
|
||||
int read = in.read(buf);
|
||||
if (read < 0) break;
|
||||
baos.write(buf, 0, read);
|
||||
}
|
||||
DataHelper.copy(in, baos);
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
|
||||
@@ -258,12 +258,7 @@ public class Base64 {
|
||||
|
||||
private static byte[] read(InputStream in) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
|
||||
byte buf[] = new byte[1024];
|
||||
while (true) {
|
||||
int read = in.read(buf);
|
||||
if (read < 0) break;
|
||||
baos.write(buf, 0, read);
|
||||
}
|
||||
DataHelper.copy(in, baos);
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
|
||||
@@ -1830,4 +1830,25 @@ public class DataHelper {
|
||||
}
|
||||
return p.split(s, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy in to out. Caller MUST close the streams.
|
||||
*
|
||||
* @param in non-null
|
||||
* @param out non-null
|
||||
* @since 0.9.29
|
||||
*/
|
||||
public static void copy(InputStream in, OutputStream out) throws IOException {
|
||||
final ByteCache cache = ByteCache.getInstance(8, 8*1024);
|
||||
final ByteArray ba = cache.acquire();
|
||||
try {
|
||||
final byte buf[] = ba.getData();
|
||||
int read;
|
||||
while ((read = in.read(buf)) != -1) {
|
||||
out.write(buf, 0, read);
|
||||
}
|
||||
} finally {
|
||||
cache.release(ba);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user