The relationship between obtaining file input stream and memory usage in JAVA
三叔
三叔 2017-06-15 09:21:27
0
3
927

Get the input stream of a file in a java program, such as the input stream of a 50M text file. At this time, has the program loaded the entire file into the memory? Has it occupied 50M of space in memory? Or is there just one entrance, and when it is necessary to loop through the contents, the contents of the file are loaded one by one?

三叔
三叔

reply all (3)
学霸

The whole thing is not loaded into the memory, but some bytes can be loaded into the cache through the buffer. The whole thing is not loaded into the memory, but some bytes can be loaded into the cache through the buffer

    淡淡烟草味

    If you just open the input stream without reading it, the file does not occupy memory. Only when the file content is read, the memory will be used accordingly, as much as you read.

      漂亮男人

      It can be loaded into memory through buffering, and this is also the case in the operating system.

        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!