Is it possible to create a File object from InputStream

前端 未结 7 751
滥情空心
滥情空心 2020-12-07 14:08

Is there any way to create a java.io.File object from an java.io.InputStream ?

My requirement is reading the File from a RAR . I am not try

相关标签:
7条回答
  • 2020-12-07 15:11

    Create a temp file first.

    File tempFile = File.createTempFile(prefix, suffix);
    tempFile.deleteOnExit();
    FileOutputStream out = new FileOutputStream(tempFile);
    IOUtils.copy(in, out);
    return tempFile;
    
    0 讨论(0)
提交回复
热议问题