比如我上传1个g的文件jvm是不是得消耗1g内存这样10个并发电脑内存就没了呀
主要在于你是怎么上传的,假如是全部读到内存中,再上传就是你这样的。
但是假如你采用流式上传,他的限制点在于你每次读取的数据量的大小。
public class Copy {
public static void main(String[] args) throws IOException {
// 1.创建流对象
FileInputStream fis = new FileInputStream("D:\\test.jpg");
FileOutputStream fos = new FileOutputStream("test_copy.jpg");
// 2.读写数据
byte[] b = new byte[1024];
int len;
while ((len = fis.read(b))!=-1) {
fos.write(b, 0 , len);
}
// 3.关闭资源
fos.close();
fis.close();
}
可以参考我之前写的这篇。
https://blog.csdn.net/lydms/article/details/107955666