写一个java获取视频流 的 代码
时间: 2023-03-12 14:35:57 浏览: 86
首先,您需要获取视频流所需的资源,然后使用下面的 Java 代码来获取视频流:URL url = new URL("视频流的URL");
InputStream inputStream = url.openStream();
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
FileOutputStream fileOutputStream = new FileOutputStream("文件保存路径");
byte[] buffer = new byte[2048];
int bytesRead = 0;
while((bytesRead = bufferedInputStream.read(buffer)) != -1) {
fileOutputStream.write(buffer, 0, bytesRead);
}
fileOutputStream.close();
阅读全文