2017-10-10 12 views
0

J'utilise un programme Java simple pour obtenir le chemin canonique d'un fichier,File.getCanonicalPath ne peut pas traiter les flux NTFS?

import java.io.*; 

public class Foo { 
    public static void main (String[] args) 
    { 
     try { 
      File file = new File(args[0]); 
      System.out.println(file.getCanonicalPath()); 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
    } 
} 

En matière de flux NTFS, il soulève exception

C:\>java Foo c:\windows\system32\calc.exe::$DATA 
java.io.IOException: The filename, directory name, or volume label syntax is inc 
orrect 
     at java.io.WinNTFileSystem.canonicalize0(Native Method) 
     at java.io.WinNTFileSystem.canonicalize(Unknown Source) 
     at java.io.File.getCanonicalPath(Unknown Source) 
     at Foo.main(Foo.java:8) 

Toutes les idées?

+0

Don » t utiliser ** :: $ DATA ** à la place utiliser java -jar Foo.jar "C: \ Utilisateurs \ SamDev \ Documents \ NetBeansProjects \ MyThreads \ dist \ README.txt" $ DATA –

Répondre

0

si le nom du fichier contient * ? vous obtiendrez java.io.IOException: Invalid argument | : vous obtiendrez java.io.IOException: Le nom de fichier, nom de répertoire ou la syntaxe d'étiquette de volume est incorrect