Limiting upload speed on Java?
问题 I'd like to programmatically limit an upload or download operation in Java. I would assume that all I'd need to do was do check how fast the upload is going and insert Thread.sleep() accordingly like so: while (file.hasMoreLines()) { String line = file.readLine(); for (int i = 0; i < line.length(); i+=128) { outputStream.writeBytes(line.substr(i, i+128).getBytes()); if (isHittingLimit()) Thread.sleep(500); } } Will the above code work? If not, is there a better way to do this? Is there a