Je suis en train de lire un fichier et l'erreur que je reçois estFileNotFoundException lorsque le fichier existe avec comme indiqué ci-dessous toutes les autorisations
java.io.FileNotFoundException: /homes/at1106/fourthYearComputing/Individual-Project/svn-workspace/trunk/Individual_Project/src/game/player/gametheoryagent/configurations/gameTheoryAgentConfiguration.properties (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at game.player.gametheoryagent.GameTheoryAgent.<init>(GameTheoryAgent.java:67)
at simulation.Simulator.createPlayer(Simulator.java:141)
at simulation.Simulator.main(Simulator.java:64)
mais le fichier existe et juste vérifier je lui ai donné 777 autorisations,:
tui% cd /homes/at1106/fourthYearComputing/Individual-Project/svn-workspace/trunk/Individual_Project/src/game/player/gametheoryagent/configurations
tui% ls -al
total 4
drwxrwxrwx 3 at1106 cs4 1024 2010-02-22 17:45 .
drwxrwxrwx 4 at1106 cs4 1024 2010-02-22 17:27 ..
-rwxrwxrwx 1 at1106 cs4 260 2010-02-22 17:31 gameTheoryAgentConfiguration.properties
drwxrwxrwx 6 at1106 cs4 1024 2010-02-22 17:41 .svn
Des idées sur les raisons pour lesquelles j'obtiens l'exception FNF?
Merci
code java qui fait l'appel:
File file = new File(pathToConfiguration)
Properties configuration = new Properties();
try{
configuration.load(new FileInputStream(file));
int RAISE_RATIO = Integer.parseInt(configuration.getProperty("raise_ratio"));
}
catch(IOException event){
System.err.println("Error in reading configuration file " + pathToConfiguration);
event.printStackTrace();
}
Le fichier de propriétés se lit ainsi:
raise_ratio=4
Cela a été testé dans les fenêtres (avec un diff pathToConfiguration (qui est passé dans le constructeur)) et fonctionne bien.
Ajouté dans les contrôles suivants dans le bloc Catch
if(file.exists()){
System.out.println("file exists");
}
else{
System.out.println("file doesn't exist");
}
System.out.println(file.getAbsolutePath());
if(file.canRead()){
System.out.println("can read");
}
if(file.canWrite()){
System.out.println("can write");
}
la sortie est la suivante:
file doesn't exist
/homes/at1106/fourthYearComputing/Individual-Project/svn-workspace/trunk/Individual_Project/src/game/player/gametheoryagent/configurations/gameTheoryAgentConfiguration.properties
Pouvez-vous coller le code Java réel? – Martin
Quel code utilisez-vous lorsque l'exception est levée? Que se passe-t-il si vous utilisez file.exists()? file.getAbsolutePath()? file.canRead/Write/Execute()? – Pops
Courez-vous votre code java sur la même machine où le fichier existe? –