Skip to content

Instantly share code, notes, and snippets.

@shreeshga
Created November 1, 2013 00:11
Show Gist options
  • Save shreeshga/7259249 to your computer and use it in GitHub Desktop.
Save shreeshga/7259249 to your computer and use it in GitHub Desktop.
block write
private static void write(InputStream dataStream, Writer writer) throws IOException {
long start = System.currentTimeMillis();
byte[] buffer = new byte[512000];
BufferedInputStream in = new BufferedInputStream(dataStream);
int bytes = -1;
try {
bytes = readline(in, buffer,512000);
} catch (IOException e) {
Utilities.print(e);
}
while (bytes > 0) {
try {
String str = new String(buffer,0,bytes);
writer.write(str);
bytes = readline(in, buffer,512000);
} catch (IOException e) {
Utilities.print(e);
}
}
writer.flush();
writer.close();
long end = System.currentTimeMillis();
Utilities.print((end - start) / 1000f + " seconds");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment