Create a File object in memory from a string in Java

后端 未结 5 1238
独厮守ぢ
独厮守ぢ 2020-12-08 12:59

I have a function that accepts File as an argument. I don\'t want to create/write a new File (I don\'t have write access to filesystem) in order to pass my string data to th

5条回答
  •  遥遥无期
    2020-12-08 13:35

    A File object in Java is a representation of a path to a directory or file, not the file itself. You don't need to have write access to the filesystem to create a File object, you only need it if you intend to actually write to the file (using a FileOutputStream for example)

提交回复
热议问题