Skip to content

Instantly share code, notes, and snippets.

@ciela
Last active December 20, 2015 14:29
Show Gist options
  • Save ciela/6146869 to your computer and use it in GitHub Desktop.
Save ciela/6146869 to your computer and use it in GitHub Desktop.
Javaで帯域制限かけながらI/Oする
byte[] buff = new byte[length];
int i;
while((i = in.read(buff, 0, length)) != -1){
long start = System.currentTimeMillis();
out.write(buff, 0, i);
long diff = System.currentTimeMillis() - start;
Thread.sleep(1000 - diff);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment