@Test public void testGetSubDirs() { String dir = TestData.getTemporaryTestDir(); Set<String> subdirs = Sets.newHashSet(); for (int i = 0; i < TestData.getScaleCount(); i++) { String subdir = TestData.getString(); FileSystem.mkdirs(FileSystem.makePath(dir, subdir)); subdirs.add(subdir); } Assert.assertEquals(subdirs, FileSystem.getSubDirs(dir)); }
public static Set<String> getSubDirs(String dir) { File directory = new File(dir); File[] files = directory.listFiles(); if(files != null) { Set<String> subDirs = Sets.newHashSet(); for (File file : files) { if(Files.isDirectory(Paths.get(file.getAbsolutePath()))) { subDirs.add(file.getName()); } } return subDirs; } else { return Collections.emptySet(); } }
FileSystem extends FileOps { public static Set<String> getSubDirs(String dir) { File directory = new File(dir); File[] files = directory.listFiles(); if(files != null) { Set<String> subDirs = Sets.newHashSet(); for (File file : files) { if(Files.isDirectory(Paths.get(file.getAbsolutePath()))) { subDirs.add(file.getName()); } } return subDirs; } else { return Collections.emptySet(); } } }
FileSystem extends FileOps { public static Set<String> getSubDirs(String dir) { File directory = new File(dir); File[] files = directory.listFiles(); if(files != null) { Set<String> subDirs = Sets.newHashSet(); for (File file : files) { if(Files.isDirectory(Paths.get(file.getAbsolutePath()))) { subDirs.add(file.getName()); } } return subDirs; } else { return Collections.emptySet(); } } private  FileSystem(); }
FileSystem extends FileOps { public static Set<String> getSubDirs(String dir) { File directory = new File(dir); File[] files = directory.listFiles(); if(files != null) { Set<String> subDirs = Sets.newHashSet(); for (File file : files) { if(Files.isDirectory(Paths.get(file.getAbsolutePath()))) { subDirs.add(file.getName()); } } return subDirs; } else { return Collections.emptySet(); } } private  FileSystem(); static void closeFileChannel(FileChannel channel); static void copyBytes(String from, String to); static void deleteDirectory(String directory); static void deleteFile(String file); static Iterator<String> fileOnlyIterator(final String directory); @SuppressWarnings("resource") // NOTE: can't close the file channel here // because others depend on it static FileChannel getFileChannel(String file); static FileChannel getFileChannel(Path file); static long getFileSize(String file); static String getSimpleName(String filename); static Set<String> getSubDirs(String dir); static boolean hasDir(String dir); static boolean hasFile(Path file); static boolean hasFile(String file); static void lock(String path); static Stream<Path> ls(Path directory); static String makePath(String... parts); static MappedByteBuffer map(String file, MapMode mode, long position,
            long size); static MappedByteBuffer map(Path file, MapMode mode, long position,
            long size); static File openFile(String file); static ByteBuffer readBytes(String file); static void replaceFile(String original, String replacement); static Iterator<String> subDirectoryOnlyIterator(
            final String directory); static void unmap(MappedByteBuffer buffer); static void writeBytes(ByteBuffer bytes, String file); static void writeBytes(ByteBuffer bytes, String file, int position); }
FileSystem extends FileOps { public static Set<String> getSubDirs(String dir) { File directory = new File(dir); File[] files = directory.listFiles(); if(files != null) { Set<String> subDirs = Sets.newHashSet(); for (File file : files) { if(Files.isDirectory(Paths.get(file.getAbsolutePath()))) { subDirs.add(file.getName()); } } return subDirs; } else { return Collections.emptySet(); } } private  FileSystem(); static void closeFileChannel(FileChannel channel); static void copyBytes(String from, String to); static void deleteDirectory(String directory); static void deleteFile(String file); static Iterator<String> fileOnlyIterator(final String directory); @SuppressWarnings("resource") // NOTE: can't close the file channel here // because others depend on it static FileChannel getFileChannel(String file); static FileChannel getFileChannel(Path file); static long getFileSize(String file); static String getSimpleName(String filename); static Set<String> getSubDirs(String dir); static boolean hasDir(String dir); static boolean hasFile(Path file); static boolean hasFile(String file); static void lock(String path); static Stream<Path> ls(Path directory); static String makePath(String... parts); static MappedByteBuffer map(String file, MapMode mode, long position,
            long size); static MappedByteBuffer map(Path file, MapMode mode, long position,
            long size); static File openFile(String file); static ByteBuffer readBytes(String file); static void replaceFile(String original, String replacement); static Iterator<String> subDirectoryOnlyIterator(
            final String directory); static void unmap(MappedByteBuffer buffer); static void writeBytes(ByteBuffer bytes, String file); static void writeBytes(ByteBuffer bytes, String file, int position);  }