List of usage examples for java.io File listRoots
public static File[] listRoots()
From source file:CheckFileTreeViewer.java
public Object[] getElements(Object arg0) { return File.listRoots(); }
From source file:com.comcast.cats.service.util.VideoRecorderUtil.java
/** * /*from w w w . j a v a 2 s .co m*/ * @return */ public static List<DiskSpaceUsage> getDiskSpaceUsage() { File[] roots = File.listRoots(); List<DiskSpaceUsage> diskSpaceUsageList = new ArrayList<DiskSpaceUsage>(); for (File file : roots) { diskSpaceUsageList.add(new DiskSpaceUsage(file)); } return diskSpaceUsageList; }
From source file:TestingNonApplication.TestMainNonApp.java
/** * Orginal method with Console print lines *///from w w w . ja v a 2 s . c o m public static void outputTestFileScan() { File[] drives = File.listRoots(); List<File> files = hyperAVAJAVAFileMp3Scan(drives[1]); List<File> files2 = hammerBack(files); for (File file : files2) { System.out.println(file.toString()); } /*for (File file : drives) { aVAJAVAFileMp3Scan(file); } for (File file : drives) { stackOverflowFileMp3Scan(file); }*/ }
From source file:org.sorcersoft.sigar.Zip.java
private static String relative(File file) { String path = file.getPath(); if (!file.isAbsolute()) { return path; }/*from w ww. ja va2 s. c om*/ for (File root : File.listRoots()) { String rootPath = root.getPath(); if (path.startsWith(rootPath)) return path.substring(rootPath.length()); } throw new IllegalArgumentException(path + " is absolute bot no root matches"); }
From source file:com.google.gdt.eclipse.designer.core.model.widgets.ClassLoaderTest.java
@DisposeProjectAfter public void test_badFileInClasspath_noSuchFile() throws Exception { {//w ww . j av a2 s . c o m String jarPathString = File.listRoots()[0].getAbsolutePath() + "noSuchFile.jar"; ProjectUtils.addExternalJar(m_javaProject, jarPathString, null); } // parseJavaInfo("public class Test implements EntryPoint {", " public void onModuleLoad() {", " RootPanel rootPanel = RootPanel.get();", " }", "}"); }
From source file:pt.ua.dicoogle.server.web.IndexerServlet.java
/** * Returns a XML document in String form containing the list of child * directories of the specified path.//from w ww . j a v a2 s.c o m * * @param path * the path of the directory to retrieve the child directories * of. * @return a XML document in String form containing the list of child * directories of the specified path. */ public static String getPathContents(String path) { File dir = null; if (path != null) dir = new File(path); // check if the specified path is a valid one, if not revert to "roots" if ((path == null) || path.trim().isEmpty() || (dir == null) || (!dir.exists()) || (!dir.isDirectory())) path = ""; else path = dir.getAbsolutePath(); // guarantee that the parent path is always a valid one (never null) String parentPath = ""; File[] childs = null; if (path.isEmpty()) { // return "roots" childs = File.listRoots(); } else { if (dir.getParent() != null) { File parent = new File(dir.getParent()); parentPath = parent.getAbsolutePath(); } // list the dir children childs = dir.listFiles(onlyDirectories); } // create the XML string builder and open the xml document StringBuilder xml = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); xml.append("<contents path=\""); xml.append(escapeHtml4(path)); xml.append("\" parent=\""); xml.append(escapeHtml4(parentPath)); xml.append("\">"); // loop through all the cildren and add their path name to the XML tree if (childs != null) { for (File child : childs) { String cName = child.getName(); String cPath = child.getAbsolutePath(); if ((cName == null) || cName.isEmpty()) cName = cPath; xml.append("<directory name=\""); xml.append(escapeHtml4(cName)); xml.append("\" path=\""); xml.append(escapeHtml4(cPath)); xml.append("\" />"); } } // close the document xml.append("</contents>"); // return the formed XML string return xml.toString(); }
From source file:org.apache.sshd.SshServerDevelopment.java
protected static final void testSftpAccess(BufferedReader in, PrintStream out, SshServer sshd) throws Exception { for (;;) {/*from w ww . j a va 2 s . c o m*/ String ans = getval(out, in, "root folder [u]ser/c(w)d/(r)oot/XXX path/(q)uit"); if (isQuit(ans)) { break; } char op = StringUtils.isEmpty(ans) ? '\0' : Character.toLowerCase(ans.charAt(0)); String path = null; switch (op) { case '\0': case 'u': path = SystemUtils.USER_HOME; break; case 'w': path = SystemUtils.USER_DIR; break; case 'r': { File[] roots = File.listRoots(); if (ArrayUtils.isEmpty(roots)) { System.err.println("No roots listed"); break; } if (roots.length == 1) { path = roots[0].getAbsolutePath(); break; } File selected = inputListChoice(out, in, "Roots", Arrays.asList(roots), null); if (selected != null) { path = selected.getAbsolutePath(); } } break; default: // assume a path path = ans; } if (StringUtils.isEmpty(path)) { continue; } final File rootDir = new File(path); NativeFileSystemFactory factory = new ExtendedNativeFileSystemFactory() { @Override protected File getSessionRootDir(Session session) { return rootDir; } }; if (!rootDir.exists()) { ans = getval(out, in, "create " + rootDir + " y/[n]/q"); if (isQuit(ans)) { continue; } if (!StringUtils.isEmpty(ans)) { factory.setCreateHome('y' == Character.toLowerCase(ans.charAt(0))); } } sshd.setFileSystemFactory(factory); break; } sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystem.Factory())); sshd.setCommandFactory(new ScpCommandFactory()); sshd.setShellFactory(ECHO_SHELL); waitForExit(in, out, sshd); }
From source file:org.kie.commons.java.nio.fs.file.SimpleFileSystemProvider.java
public SimpleFileSystemProvider() { this(File.listRoots(), OSType.currentOS()); }
From source file:com.twosigma.beaker.core.rest.FileIORest.java
@GET @Path("getLocalDrives") public List<String> getLocalDrives() { List<String> roots = new LinkedList<>(); for (File file : File.listRoots()) { roots.add(file.getAbsolutePath()); }//from ww w . j a v a 2 s .co m return roots; }
From source file:io.fabric8.tooling.archetype.builder.ArchetypeBuilderTest.java
@Test public void relativePaths() throws Exception { Arrays.asList(File.listRoots()); File base = new File("/tmp/x"); File nested = new File("/tmp/x/y"); assertThat(archetypeUtils.relativePath(base, nested), equalTo("y")); // base = new File("/tmp/x"); // nested = new File("/bin/y"); // assertThat(archetypeUtils.relativePath(base, nested), equalTo("/bin/y")); base = new File("/tmp/x"); nested = new File("/tmp/x"); assertThat(archetypeUtils.relativePath(base, nested), equalTo("")); base = new File("/tmp/x/.."); nested = new File("/tmp/x"); assertThat(archetypeUtils.relativePath(base, nested), equalTo("x")); }