Created
November 1, 2013 00:11
-
-
Save shreeshga/7259249 to your computer and use it in GitHub Desktop.
block write
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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