Bonjour,

j'ai écrit en Java une extension pour OpenOffice Writer (Japanese Integrated Learning Tool). Je dormais tranquille sur mes deux oreilles car j'avais testé le programme sous Linux et Windows 7 RC et il fonctionnait.
J'ai reçu récemment un message d'un utilisateur sous Windows XP qui m'alerte sur un non fonctionnement.
En bref le programme ne parvient pas à ouvrir les fichiers lexicaux.

Voici le code que j'utilise pour retrouver les fichiers qui sont incorporés à l'archive (.oxt)

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
 //retrieve the path to the dictionary files
        XPackageInformationProvider xPackInfProv =PackageInformationProvider.get(m_xContext);
        stringURL = xPackInfProv.getPackageLocation("com.zoraldia.openoffice.Jilt");
        URL theURL = null;
        try {
            theURL = new URL(stringURL);
        } catch (MalformedURLException ex) {
            Logger.getLogger(Jilt.class.getName()).log(Level.SEVERE, null, ex);
        }
 
        filePath = theURL.getPath() + File.separator + "description" + File.separator +
                "resources" + File.separator;
        // a remettre filePath = s+File.separator;// filePath = userDir + File.separator + "jilt" + File.separator;// a remettre filePath = s+File.separator;
        m_edictDictionary = new Dictionary(filePath + "edict-u", "Edict");
        m_enamDictionary = new Dictionary(filePath + "enamdict-u", "Enam");
        m_kanjiDictionary = new KanjiDictionary(filePath + "kanjidic-u");
et voici la class Dictionary

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class Dictionary {
 
    String dicFileName = "";
    String signature = "";
    public boolean dictEnabled;
 
    /**
     * @param dicFileName A String representing the name of the edict  file which contains the dictionary entries
     * Each entry correspond to a line of the file
     * The dictionary must be EUC-JP coded.
     * @exception exceptions No exceptions thrown
     */
    Dictionary(String p_dicFileName, String p_signature) {
        dicFileName = p_dicFileName;
        signature = p_signature;
    }
 
    @SuppressWarnings("unchecked")
    ArrayList searchFromEnglish(String expression) {
        if (!dictEnabled) {
            return null;
        }
 
        ArrayList matches = new ArrayList();
 
        expression = expression.trim();
        BufferedReader i = null;
        try {
            i = new BufferedReader(new InputStreamReader(new FileInputStream(dicFileName), "UTF-8"));
            String str1 = null;
            while ((str1 = i.readLine()) != null) {
                if (str1.contains(expression)) {
                    matches.add(str1);
                }
 
            }
            i.close();
            return matches;
 
        } catch (Exception ex) {
            ex.printStackTrace(System.out);
            System.out.println(ex.getMessage());
            return null;
 
        } finally {
            try {
                i.close();
            } catch (IOException ex) {
                ex.printStackTrace();
                System.out.println(ex.getMessage());
                Logger.getLogger(Dictionary.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
Apparemment, le path est recréé correctement mais voici le genre de message d'erreur que je reçois (ici en mode debug ce qui explique le nom de répertoire temporaire dans le path)

java.io.FileNotFoundException: C:\Documents%20and%20Settings\esoj\My%20Documents\NetBeansProjects\Jilt\build\soffice_debug\user\uno_packages\cache\uno_packages\D.tmp_\Jilt.oxt\description\resources\edict-u (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at com.zoraldia.openoffice.Dictionary.searchExactWritingMatches(Dictionary.java:196)
at com.zoraldia.openoffice.DictionaryDialog.searchDictionary(DictionaryDialog.java:1000)
at com.zoraldia.openoffice.DictionaryDialog.searchDictionary(DictionaryDialog.java:938)
at com.zoraldia.openoffice.DictionaryDialog$buttonActionListener.actionPerformed(DictionaryDialog.java:453)
at com.sun.star.bridges.jni_uno.JNI_proxy.dispatch_call(Native Method)
at com.sun.star.bridges.jni_uno.JNI_proxy.invoke(JNI_proxy.java:178)
at $Proxy38.execute(Unknown Source)
at com.zoraldia.openoffice.DictionaryDialog.showDialog(DictionaryDialog.java:206)
at com.zoraldia.openoffice.Jilt.dispatch(Jilt.java:391)
Si je parcours le path manuellement je peux accéder au fichier (ici edict-u).

Pour aller plus loin, j'ai introduit dans le programme les instructions suivantes;

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
File theDir=new File (filePath);
System.out.println("Exist?= :"+theDir.exists());
System.out.println("Can read?= :"+theDir.canRead());
J'obtiens en retour;
Exist?= false
Can read?=: false

Quelqu'un pourrait-il m'aider à comprendre ce qui ne va pas?