Java code:
URL urlw = new URL("http://95.161.19.3:8000/low"); HttpURLConnection Connection = (HttpURLConnection) urlw.openConnection(); recordingStream = Connection.getInputStream(); byte[] buffer= new byte[1]; while (true){ if (recordingStream.read(buffero, 0, 1) != -1 && isFlg) { writer.write(buffer, 0, 1); // запись в файл. writer.flush(); } }
It reads a stream in a loop one by one (!) Byte and writes this byte to a binary file. Apparently it was developed in the days of GPRS. Increasing the buffer results in a loss of bytes. The file is not read.
Python code:
bp = urllib.urlopen("http://95.161.19.3:8000/low") while True: dpa=bp.read(1024) // да хоть 1000000, и без потерь. writer.write(dpa)
Question, is it also possible in java ?