FULL PRODUCT VERSION : java version "1.6.0" Java(TM) SE Runtime Environment (build 1.6.0-b105) Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode) ADDITIONAL OS VERSION INFORMATION : Microsoft Windows XP [version 5.1.2600] A DESCRIPTION OF THE PROBLEM : Hi, The java.awt.Desktop class does not allow to open a network file with blank character into the path. For example, it fails to open "//serverName/drive/Temp/my folder/a simple file.xxx", where xxx may be any extension : txt, pdf... For information, it works if the path contains the drive letter "N:/Temp/my folder/a simple file.txt", or if the path does not contain any blank like "//serverName/drive/Temp/my_folder/a_simple_file.txt". EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - Should open the file with the application used for its extension, like Notepad for txt file. ACTUAL - IOException ERROR MESSAGES/STACK TRACES THAT OCCUR : The ouput is: java.io.IOException: Failed to open file:////serverName/drive/Temp/my%20folder/a%20simple%20file.txt. Error message: Le chemin d'acc��s sp��cifi�� est introuvable. at sun.awt.windows.WDesktopPeer.ShellExecute(Unknown Source) at sun.awt.windows.WDesktopPeer.open(Unknown Source) at java.awt.Desktop.open(Unknown Source) at Swing.myDesktop.main(jvDesktop.java:26) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- package Swing; import java.awt.*; import java.io.*; public class myDesktop { public static void main(String[] args) { try { Desktop myDesktop = null; if (Desktop.isDesktopSupported()) myDesktop = Desktop.getDesktop(); if (myDesktop != null) { // -> Works //File myFile = new File("//sma-nasft04-1/servev/Temp/my_folder/a_simple_file.txt"); //File myFile = new File("N:/Temp/my folder/a simple file.txt"); // -> Does not work File myFile = new File("//sma-nasft04-1/servev/Temp/my folder/a simple file.txt"); if (myFile.exists()) myDesktop.open(myFile); else System.out.println("This file is not a valid one"); } } catch (IOException e) { e.printStackTrace(); } } } ---------- END SOURCE ----------
|