为什么在Linux上存在FileNotFoundException?

为什么在Linux上存在FileNotFoundException?,第1张

概述为什么在Linux上存在FileNotFoundException?

这是我第一次在linux上遇到Java的文件访问问题。 问题就像标题所示 – 当文件实际存在时抛出fileNotFoundException 。 而且,具有相同configuration(props.txt文件)的应用程序在windows上应该可以运行。 让我提供一些控制台输出

datasu @ dedi2392:〜/ netcrawler / dkpto $ ls -l

共20个

-rwxrw-rw- 1 datasu datasu 114 Aug 7 15:53 autoupdate

drwxr-xr-x 4 datasu datasu 4096 Aug 8 11:57 data

drwxr-xr-x 2 datasu datasu 4096 Aug 8 11:57 log

-rw-rw-rw- 1 datasu datasu 32 8月8日12:44 props.txt

-rwxrw-rw- 1 datasu datasu 126 Aug 8 12:55 propsUpdate

datasu @ dedi2392:〜/ netcrawler / dkpto $ ./propsUpdate

父:/ usr / home / datasu / netcrawler / dkpto

1# - >道具更新

2# - > autoupdate

3# - > props.txt

4# - >数据

5# - >日志

(没有这样的文件或目录)ava.io.fileNotFoundException:/usr/home/datasu/netcrawler/dkpto/props.txt

在java.io.fileinputStream.open(Native Method)

在java.io.fileinputStream。(UnkNown Source)

在netcrawler.autoupdater.readPropertIEs(autoupdater.java:71)

在netcrawler.autoupdater.start(autoupdater.java:54)

在netcrawler.autoupdater.main(autoupdater.java:47)

datasu @ dedi2392:〜/ netcrawler / dkpto $ java -version

java版本“1.6.0_45”

Java(TM)SE运行时环境(版本1.6.0_45-b06)

Java HotSpot(TM)64位服务器虚拟机(构build20.45-b01,混合模式)

datasu @ dedi2392:〜/ netcrawler / DKPTO $

这里是负责生成该输出的Java代码(至less在调用./propsUpdate )

private voID readPropertIEs(String args) throws fileNotFoundException,IOException { System.out.println("Parent: " + new file(args).getabsolutefile().getParentfile().getabsolutePath()); CommonTools.PrintArray(new file(args).getabsolutefile().getParentfile().List()); propertIEs.load(new fileinputStream(new file(args).getabsolutefile())); // this line throws the exception stageNumber = Integer.parseInt(propertIEs.getProperty(PROP_STAGE_NUMBER_KEY,"0")); }

那么为什么props.txt文件实际上没有find?

如何从所有子目录合并具有相同名称的文本文件?

将子文件夹中的文件移动到文件夹并重命名windows提示

查看由数字表示的文件的特定行

用C ++自定义标准input到系统调用

为什么补丁找不到这个文件?

使用windows cmdrecursion删除0KB文件

传递batch file的参数

linux将数据从一个文件前置到另一个文件

使用robo复制和过程的文件复制

与goto命令不起作用的windowsbatch file

字符串“args”最后可能有一个非打印字符,就像一个空格。 在使用该变量之前,可以使用String.trim()来删除这些字符。

你的主文件夹真的是这个路径吗?

/usr/home/datasu

/home/datasu是通常在linux上的地方。

另外,尝试改变这一行:

propertIEs.load(new fileinputStream(new file(args));

如果您将其称为./propsUpdate ./props.txt ,它将从当前工作目录中运行。

总结

以上是内存溢出为你收集整理的为什么在Linux上存在FileNotFoundException?全部内容,希望文章能够帮你解决为什么在Linux上存在FileNotFoundException?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1155377.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-01
下一篇 2022-06-01

发表评论

登录后才能评论

评论列表(0条)

保存