Java File to Binary Conversion

后端 未结 3 802
半阙折子戏
半阙折子戏 2020-12-10 09:20

How can i convert File to Binary? I just need it for my project. I need to encrypt a file by its binaries.

3条回答
  •  死守一世寂寞
    2020-12-10 09:58

    With FileInputStream you can obtain the bytes from a File

    From JavaDoc:

    A FileInputStream obtains input bytes from a file in a file system. What files are available depends on the host environment.

    FileInputStream is meant for reading streams of raw bytes such as image data. For reading streams of characters, consider using FileReader.

提交回复
热议问题