code:     public static File resolve(File[] roots, String path) {
          for (File root : roots) {
              File file = new File(path);
              final File normalizedPath;
              try {
                  if (file.isAbsolute()) {
                      normalizedPath = file.getCanonicalFile();
                  } else {
                      normalizedPath = new File(root, path).getCanonicalFile();
                  }
              } catch (IOException ex) {
                  continue;
              }
              if(normalizedPath.getAbsolutePath().startsWith(root.getAbsolutePath())) {
                  return normalizedPath;
              }
          }
          return null;
      }
  
  
  