Why FileWriter doesn't create a new file?

后端 未结 1 1820
予麋鹿
予麋鹿 2021-01-21 01:51

Consider the following code:

 m_Writer = new PrintWriter(new FileWriter(\"LoginHistory.dat\")); 
 m_Writer.println(Integer.toString(s_NumOfLogins)); 
 m_Writer         


        
1条回答
  •  孤城傲影
    2021-01-21 02:58

    It seems plain that you don't have permission to create that file where you're trying to create it, hence the "Access denied" message. You'd need to find a directory where you're allowed to create files. If you're not sure where a file is going to be created, you can see its full path with File.getAbsolutePath() or File.getCanonicalPath().

    0 讨论(0)
提交回复
热议问题