从命令行参数读取文件时发生Java FileNotFoundException
file类在哪个目录中查找文件?我的代码在一个单独的项目中工作。我在源目录和更高的目录中有project2.torrent文件。我很确定这是个小东西。希望我没有含糊不清从命令行参数读取文件时发生Java FileNotFoundException,java,file,Java,File,file类在哪个目录中查找文件?我的代码在一个单独的项目中工作。我在源目录和更高的目录中有project2.torrent文件。我很确定这是个小东西。希望我没有含糊不清 java.io.FileNotFoundException: project2.torrent (The system cannot find the file specified) at java.io.FileInputStream.open(Native Method) at java.io.FileInp
java.io.FileNotFoundException: project2.torrent (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at RUBTClient.parsing(RUBTClient.java:31)
at RUBTClient.main(RUBTClient.java:17)
java.io.FileNotFoundException:project2.torrent(系统找不到指定的文件)
在java.io.FileInputStream.open(本机方法)
位于java.io.FileInputStream。(FileInputStream.java:146)
解析(RUBTClient.java:31)
位于RUBTClient.main(RUBTClient.java:17)
file类在哪个目录中查找文件
它查看当前目录,通常是从java启动的地方
你可以通过阅读
System.out.println(System.getProperty("user.dir"));
非常感谢。这就解决了问题。我以为我在另一个目录下工作,我正在查看的目录有我的文件的副本。