简体   繁体   English

java.io.FileNotFoundException:控制台中信息的含义是什么?

[英]java.io.FileNotFoundException: what's the meaning of information in console?

I try to run a I/O java code but console this kind of information. 我尝试运行I / O Java代码,但可以管理此类信息。 Does this just mean the necessary input file PhaseII_Input_Demand.csv can not found? 这是否仅表示找不到必要的输入文件PhaseII_Input_Demand.csv? How can I check if this some other error? 如何检查其他错误?

java.io.FileNotFoundException: /Users/shenjiajie/Desktop/15min/PhaseII_Input_Demand.csv (No such file or directory)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:195)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at java.io.FileInputStream.<init>(FileInputStream.java:93)
    at java.io.FileReader.<init>(FileReader.java:58)
    at interfaces.Phase2IO.loadCLDemand(Phase2IO.java:249)
    at interfaces.Phase2IO.runPhaseII(Phase2IO.java:91)
    at interfaces.MainInterface.jButton2ActionPerformed(MainInterface.java:400)
    at interfaces.MainInterface.access$5(MainInterface.java:394)
    at interfaces.MainInterface$3.actionPerformed(MainInterface.java:257)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6525)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at java.awt.Component.processEvent(Component.java:6290)
    at java.awt.Container.processEvent(Container.java:2234)
    at java.awt.Component.dispatchEventImpl(Component.java:4881)
    at java.awt.Container.dispatchEventImpl(Container.java:2292)
    at java.awt.Component.dispatchEvent(Component.java:4703)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
    at java.awt.Container.dispatchEventImpl(Container.java:2278)
    at java.awt.Window.dispatchEventImpl(Window.java:2750)
    at java.awt.Component.dispatchEvent(Component.java:4703)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

This expression mean your file(PhaseII_Input_Demand.csv) file dose not exit in computer. 此表达式表示您的文件(PhaseII_Input_Demand.csv)文件未在计算机中退出。 The other meaning is you are wrong directory. 另一个意思是您的目录错误。 Please check your directory. 请检查您的目录。

You wrong the last "/" in the directory. 您错误了目录中的最后一个“ /”。 Please replace with the following. 请替换以下内容。

/Users/shenjiajie/Desktop/15min/PhaseII_Input_Demand.csv

Good luck! 祝好运!

Please try to remove the blanks in the string "/Users/shenjiajie/Desktop/15min/PhaseII_Input_Demand.csv" (the one between "15min" and the slash, as well as the one right after that slash), and see if it works. 请尝试删除字符串“ /Users/shenjiajie/Desktop/15min/PhaseII_Input_Demand.csv”中的空格(“ 15min”和斜杠之间的空格,以及该斜杠之后的空格),然后查看是否可行。 Thanks and good luck! 谢谢,祝你好运!

EDIT: Thanks to @TJCrowder, actually there are not blanks - the last slash is wrong (looks like a full Chinese character). 编辑:感谢@TJCrowder,实际上没有空格-最后一个斜杠是错误的(看起来像一个完整的汉字)。 @T8Z is correct. @ T8Z是正确的。

  1. In this path: /Users/shenjiajie/Desktop/15min/PhaseII_Input_Demand.csv , can you notice that after 15min, the forward slash looks little different, like some space is present. 在以下路径中: /Users/shenjiajie/Desktop/15min/PhaseII_Input_Demand.csv ,您是否可以注意到,在15分钟之后,斜杠看起来没有什么不同,就像存在一些空格一样。
  2. And are you sure that you are passing with double forward slashes // between the directories like: //Users//shenjiajie//Desktop//15min//PhaseII_Input_Demand.csv ? 并且您确定要在目录之间使用//双斜杠// //Users//shenjiajie//Desktop//15min//PhaseII_Input_Demand.csv吗?

  3. Are you using Windows, did you mean to retrieve it from C: drive? 您是否正在使用Windows,是否意味着要从C:驱动器中检索它? Then pass it like: "C://Users//shenjiajie//Desktop//15min//PhaseII_Input_Demand.csv" 然后将其传递为: "C://Users//shenjiajie//Desktop//15min//PhaseII_Input_Demand.csv"

  4. You could use file.exists() to know if file really exists. 您可以使用file.exists()来确定文件是否确实存在。

     File f = new File("C://Users//shenjiajie//Desktop//15min//PhaseII_Input_Demand.csv"); if(f.exists()) { //start next operation } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM