我尝试运行I / O java代码但是控制这种信息。这是否意味着无法找到必要的输入文件PhaseII_Input_Demand.csv?如何检查是否存在其他错误?
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)
答案 0 :(得分:2)
此表达式表示您的文件(PhaseII_Input_Demand.csv)文件未在计算机中退出。另一个意思是你错了目录。请检查您的目录。
你错了上一个&#34; /&#34;在目录中。请替换为以下内容。
/Users/shenjiajie/Desktop/15min/PhaseII_Input_Demand.csv
祝你好运!
答案 1 :(得分:1)
请尝试删除字符串“/Users/shenjiajie/Desktop/15min/PhaseII_Input_Demand.csv”中的空格(“15min”和斜杠之间的空格,以及斜杠之后的空格),然后查看如果有效。谢谢,祝你好运!
编辑:感谢@ T.J.Crowder,实际上没有空白 - 最后一个斜线是错误的(看起来像一个完整的中文字符)。 @ T8Z是正确的。答案 2 :(得分:0)
/Users/shenjiajie/Desktop/15min/PhaseII_Input_Demand.csv
,你能注意到15分钟后,正斜杠看起来有点不同,就像有一些空间一样。 你确定你在以下目录之间传递了双正斜杠//://Users//shenjiajie//Desktop//15min//PhaseII_Input_Demand.csv
?
您使用的是Windows,是不是要从C:驱动器中检索它?然后将其传递给:"C://Users//shenjiajie//Desktop//15min//PhaseII_Input_Demand.csv"
您可以使用file.exists()来了解文件是否真的存在。
File f = new File("C://Users//shenjiajie//Desktop//15min//PhaseII_Input_Demand.csv");
if(f.exists())
{
//start next operation
}