【发布时间】:2023-03-15 08:46:01
【问题描述】:
我的文件夹中有许多张图片。我想为所有图像(字节数组数组)制作一个字节数组,但我只设法为一张图像制作了一个数组。
File file = new File("D:\\swim\\swim99.png");
//init array with file length
byte[] bytesArray = new byte[(int) file.length()];
FileInputStream fis = new FileInputStream(file);
fis.read(bytesArray); //read file into bytes[]
fis.close();
System.out.print(Arrays.toString(bytesArray));
那么我可以一次访问一个文件夹中的多个图像并获取每个字节数组,然后将它们放入数组数组的二维数组中,其中[Number of image[byte array image one]]?
预期输出:A[image Number][It's byte array]
【问题讨论】:
-
为什么?通常您将显示图像,因此您应该直接从输入流中创建它们。您不希望在内存中再复制一份数据。
标签: java arrays arraylist java-8 rgb