创建文件时为8192字节 [英] 8192 bytes when creating file
问题描述
在我的Java代码中,我具有在http请求中从客户端获取文件并将其转换为文件的功能.我在这里有这行:
In my Java code I have function that gets file from the client in http request and converts that in to the file. I have this line there:
byte[] buffer = new byte[8192];
8192个字节(8 kb)在这里意味着什么?
what does 8192 bytes (8 kb) means here?
这是我得到的回复之一,并且想确保我理解该代码.
This is one of the responses that I got, and want to make sure that I understand that code.
推荐答案
它使用缓冲区一次读取和写入8kB块.该数字相当随意,但是出于性能方面的考虑,在写入文件时使用512字节的倍数是有意义的,最好是磁盘簇大小的倍数.对于大多数用途,8kB是合理的缓冲区大小.
That it uses a buffer to read and write 8kB blocks at once. The number is fairly arbitary, but for performance reasons it makes sense to use a multiple of 512 bytes when writing a file, and preferably a multiple of the disks cluster size. 8kB is a reasonable buffer size for most purposes.
这篇关于创建文件时为8192字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!