예제 #1
0
 /** Returns a File object constructed from the given path string. */
 public File createFileObject(String path) {
   // Check for missing backslash after drive letter such as "C:" or "C:filename"
   if (path.length() >= 2 && path.charAt(1) == ':' && Character.isLetter(path.charAt(0))) {
     if (path.length() == 2) {
       path += "\\";
     } else if (path.charAt(2) != '\\') {
       path = path.substring(0, 2) + "\\" + path.substring(2);
     }
   }
   return super.createFileObject(path);
 }
예제 #2
0
  public File getChild(File parent, String fileName) {
    if (fileName.startsWith("\\") && !fileName.startsWith("\\\\") && isFileSystem(parent)) {

      // Path is relative to the root of parent's drive
      String path = parent.getAbsolutePath();
      if (path.length() >= 2 && path.charAt(1) == ':' && Character.isLetter(path.charAt(0))) {

        return createFileObject(path.substring(0, 2) + fileName);
      }
    }
    return super.getChild(parent, fileName);
  }