Construct a java.io.File that reads from a byte array

后端 未结 4 678
失恋的感觉
失恋的感觉 2021-01-20 05:49

I\'m using an API that requires a java.io.File as input, but I\'d like to just send the API a byte array. Is there a way to create a File object that will read from my byte

4条回答
  •  庸人自扰
    2021-01-20 06:31

    A File does not read anything. It represents a file (or directory) object in the Operating System (or virtual file, etc.). To read from it, you wil have to create Readers or Streams, which the API will do on its own. If the API does not provide methods to pass in a Reader or InputStream, you are out of luck.

提交回复
热议问题