@@ -0,0 +1,865 @@
+package ru.r2cloud.jradio.util;%0A%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0A%0Apublic class ThrottledInputStream extends InputStream %7B%0A%0A%09private final InputStream source;%0A%0A%09private final byte%5B%5D tempBuffer;%0A%0A%09public ThrottledInputStream(int bandwidth, InputStream source) %7B%0A%09%09this.source = source;%0A%09%09this.tempBuffer = new byte%5Bbandwidth%5D;%0A%09%7D%0A%0A%09@Override%0A%09public int read(byte%5B%5D b, int off, int len) throws IOException %7B%0A%09%09if( tempBuffer.length %3E= len ) %7B%0A%09%09%09//read directly into the target buffer%0A%09%09%09return source.read(b, off, len);%0A%09%09%7D%0A%09%09int bytesRead = source.read(tempBuffer);%0A%09%09if (bytesRead %3C 0) %7B%0A%09%09%09return -1;%0A%09%09%7D%0A%09%09System.arraycopy(tempBuffer, 0, b, off, bytesRead);%0A%09%09return bytesRead;%0A%09%7D%0A%0A%09@Override%0A%09public int read() throws IOException %7B%0A%09%09return source.read();%0A%09%7D%0A%0A%09@Override%0A%09public void close() throws IOException %7B%0A%09%09source.close();%0A%09%7D%0A%0A%7D%0A

read fully in lrptinputstream