What is a safe way to create a Temp file in Java?

前端 未结 3 856
挽巷
挽巷 2020-12-23 15:44

I\'m looking for a safe way to create a temp file in Java. By safe, I mean the following:

  • Name should be unique, even under potential race co
3条回答
  •  [愿得一人]
    2020-12-23 16:28

    String tempfilePath = System.getProperty("java.io.tmpdir");
    tempfilePath = tempfilePath.concat("filename.extension");
    

    doesn't require prefix.

提交回复
热议问题