我正在制作一个程序,从服务器读取视频文件并重现它们。我正在按段(秒)读取文件,为此我需要发出多个http请求,我的问题是,一旦我发出新请求,输入流仍然有来自上一个请求的数据。
示例
String server = "localhost";
int port = 8080;
socket = new Socket(server, port);
os.write(("GET /Lifted-" + "160" + "p.dat HTTP/1.0\r\n\r\n").getBytes());
OutputStream os = socket.getOutputStream();
InputStream rcv = socket.getInputStream();
.................................................................
socket = new Socket(server, port);
OutputStream os = socket.getOutputStream();
InputStream rcv = socket.getInputStream();
os.write(("GET /Lifted-" + currentRes + "p.dat HTTP/1.0\r\n\r\n").getBytes());
os.write(("Range: bytes="+Integer.toString(offset)+"-"+Integer.toString((int) (offset+aux))).getBytes());
DataInputStream dis = new DataInputStream(rcv);