How to read the file content into a variable in one go?

后端 未结 3 1815
甜味超标
甜味超标 2021-01-31 03:22

In Java, if you know for certain a file is very small, you can use readBytes() method to read the content in one go instead of read it line by line or using buffer.

3条回答
  •  一生所求
    2021-01-31 04:01

    Another alternative is to use the nice mapfile builtin:

    mapfile < test.file
    echo "${MAPFILE[@]}"
    

提交回复
热议问题