java - Why FileNotFoundException is thrown while it exists on linux -


this first time have encounter such problem file access java on linux. problem header says - filenotfoundexception thrown when file exists. application same configuration (props.txt file) runs should on windows. let me provide little bit of console output

 datasu@dedi2392:~/netcrawler/dkpto$ ls -l total 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 aug  8 12:44 props.txt -rwxrw-rw- 1 datasu datasu  126 aug  8 12:55 propsupdate datasu@dedi2392:~/netcrawler/dkpto$ ./propsupdate parent: /usr/home/datasu/netcrawler/dkpto    1# -> propsupdate    2# -> autoupdate    3# -> props.txt    4# -> data    5# -> log  (no such file or directory)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 version "1.6.0_45" java(tm) se runtime environment (build 1.6.0_45-b06) java hotspot(tm) 64-bit server vm (build 20.45-b01, mixed mode) datasu@dedi2392:~/netcrawler/dkpto$ 

and here java code responsible generating output (at least after calling ./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())); // line throws exception     stagenumber = integer.parseint(properties.getproperty(prop_stage_number_key, "0")); } 

so why props.txt file not found when there ?

the string "args" has nonprinting character @ end, space. use string.trim() remove such characters before using variable.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -