本文整理了Java中java.io.File.listRoots()
方法的一些代码示例,展示了File.listRoots()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。File.listRoots()
方法的具体详情如下:
包路径:java.io.File
类名称:File
方法名:listRoots
[英]Returns the file system roots. On Android and other Unix systems, there is a single root, /.
[中]返回文件系统根。在Android和其他Unix系统上,只有一个根/。
代码示例来源:origin: google/guava
/** Returns a root path for the file system. */
private static File root() {
return File.listRoots()[0];
}
代码示例来源:origin: k9mail/k-9
/**
* @param file
* Canonical file to match. Never <code>null</code>.
* @return Whether the specified file matches a filesystem root.
* @throws IOException
*/
public static boolean isMountPoint(final File file) {
for (final File root : File.listRoots()) {
if (root.equals(file)) {
return true;
}
}
return false;
}
代码示例来源:origin: stackoverflow.com
File[] roots = File.listRoots();
for(int i = 0; i < roots.length ; i++)
System.out.println("Root["+i+"]:" + roots[i]);
代码示例来源:origin: apache/geode
public List<String> getRoots() {
File[] roots = File.listRoots();
return Arrays.stream(roots).map(File::getAbsolutePath).collect(Collectors.toList());
}
代码示例来源:origin: ACRA/acra
@NonNull
@Override
public File getFile(@NonNull Context context, @NonNull String fileName) {
String[] parts = fileName.split(Pattern.quote(File.separator), 2);
if (parts.length == 1) return new File(fileName);
final File[] roots = File.listRoots();
for (File root : roots) {
if (parts[0].equals(root.getPath().replace(File.separator, ""))) {
return new File(root, parts[1]);
}
}
return new File(roots[0], fileName);
}
};
代码示例来源:origin: stackoverflow.com
File[] roots = File.listRoots();
代码示例来源:origin: stackoverflow.com
File[] roots = File.listRoots();
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
File retVal = File.listRoots()[0];
File pureCanonicalFile = retVal;
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
public void run() {
LOG.fine("refreshAll - started"); //NOI18N
refreshFor(File.listRoots());
try {
getConfigRoot().getFileSystem().refresh(true);
} catch (FileStateInvalidException ex) {
Exceptions.printStackTrace(ex);
} finally {
LOG.fine("refreshAll - finished"); //NOI18N
synchronized (REFRESH_RP) {
refreshTask = null;
}
}
}
});
代码示例来源:origin: spotbugs/spotbugs
public void havePermissions() throws InterruptedException {
final AtomicBoolean b = new AtomicBoolean(false);
Thread t = new Thread() {
@Override
public void run() {
b.set(true);
}
};
t.start();
t.join();
assertEquals(true, b.get());
for (File f : File.listRoots()) {
f.listFiles();
}
}
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
/**
* Registers <code>listener</code> so that it will receive
* <code>FileEvent</code>s from <code>FileSystem</code>s providing instances
* of <code>FileObject</code> convertible to <code>java.io.File</code>.
* @param fcl
* @see #toFileObject
* @since 7.7
*/
public static void addFileChangeListener(FileChangeListener fcl) {
FileSystem fs = getDiskFileSystem();
if (fs == null) {fs = getDiskFileSystemFor(File.listRoots());}
if (fs != null) {
fs.addFileChangeListener(fcl);
}
}
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
/**
* Unregisters <code>listener</code> so that it will no longer receive
* <code>FileEvent</code>s from <code>FileSystem</code>s providing instances
* of <code>FileObject</code> convertible to <code>java.io.File</code>
* @param fcl
* @see #toFileObject
* @since 7.7
*/
public static void removeFileChangeListener(FileChangeListener fcl) {
FileSystem fs = getDiskFileSystem();
if (fs == null) {fs = getDiskFileSystemFor(File.listRoots());}
if (fs != null) {
fs.removeFileChangeListener(fcl);
}
}
代码示例来源:origin: mabe02/lanterna
File[] roots = File.listRoots();
for (final File entry : roots) {
if (entry.canRead()) {
代码示例来源:origin: jphp-group/jphp
@Signature
public static Memory listRoots(Environment env, Memory... args) {
ArrayMemory r = new ArrayMemory();
File[] roots = File.listRoots();
if (roots == null)
return r.toConstant();
for(File e : roots) {
r.add(new FileObject(env, e));
}
return r.toConstant();
}
代码示例来源:origin: vert-x3/vertx-web
private void setRoot(String webRoot) {
Objects.requireNonNull(webRoot);
if (!allowRootFileSystemAccess) {
for (File root : File.listRoots()) {
if (webRoot.startsWith(root.getAbsolutePath())) {
throw new IllegalArgumentException("root cannot start with '" + root.getAbsolutePath() + "'");
}
}
}
this.webRoot = webRoot;
}
代码示例来源:origin: stackoverflow.com
File[] paths;
FileSystemView fsv = FileSystemView.getFileSystemView();
// returns pathnames for files and directory
paths = File.listRoots();
// for each pathname in pathname array
for(File path:paths)
{
// prints file and directory paths
System.out.println("Drive Name: "+path);
System.out.println("Description: "+fsv.getSystemTypeDescription(path));
}
代码示例来源:origin: SeanDragon/protools
public static boolean haveDiskD() {
if (haveDiskD == null) {
if (isWindows()) {
for (final File file : File.listRoots()) {
if (file.isDirectory() && file.getAbsolutePath().toLowerCase().contains("d")) {
haveDiskD = true;
}
}
}
haveDiskD = false;
}
return haveDiskD;
}
}
代码示例来源:origin: stackoverflow.com
File[] f = File.listRoots();
for (int i = 0; i < f.length; i++)
代码示例来源:origin: stackoverflow.com
public static void main(String args[]){
List <File>files = Arrays.asList(File.listRoots());
for (File f : files) {
String s1 = FileSystemView.getFileSystemView().getSystemDisplayName (f);
代码示例来源:origin: glowroot/glowroot
File[] roots = File.listRoots();
if (roots != null) {
for (File root : roots) {
内容来源于网络,如有侵权,请联系作者删除!