本文整理汇总了Java中java.nio.file.FileSystems.getDefault方法的典型用法代码示例。如果您正苦于以下问题:Java FileSystems.getDefault方法的具体用法?Java FileSystems.getDefault怎么用?Java FileSystems.getDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.file.FileSystems
的用法示例。
在下文中一共展示了FileSystems.getDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import java.nio.file.FileSystems; //导入方法依赖的package包/类
@Before
public void setUp() {
classLoader = new FakeClassLoader();
fileSupport = new FileSupport() {
@Override
public boolean isDirectory(Path path) {
return true;
}
@Override
public Path getSubDirectory(FileSystem fileSystem, Path root, Path path) throws IOException {
if (getSubDirectory == null) {
throw new IOException("Nope");
}
return getSubDirectory.apply(root, path);
}
};
target = new ModuleSourceProvider(FileSystems.getDefault(), classLoader, fileSupport);
}
示例2: testExtractBatchSpreadsheetWithArea
import java.nio.file.FileSystems; //导入方法依赖的package包/类
@Test
public void testExtractBatchSpreadsheetWithArea() throws ParseException, IOException {
FileSystem fs = FileSystems.getDefault();
String expectedCsv = UtilsForTesting.loadCsv("src/test/resources/technology/tabula/csv/spreadsheet_no_bounding_frame.csv");
Path tmpFolder = Files.createTempDirectory("tabula-java-batch-test");
tmpFolder.toFile().deleteOnExit();
Path copiedPDF = tmpFolder.resolve(fs.getPath("spreadsheet.pdf"));
Path sourcePDF = fs.getPath("src/test/resources/technology/tabula/spreadsheet_no_bounding_frame.pdf");
Files.copy(sourcePDF, copiedPDF);
copiedPDF.toFile().deleteOnExit();
this.csvFromCommandLineArgs(new String[]{
"-b", tmpFolder.toString(),
"-p", "1", "-a",
"150.56,58.9,654.7,536.12", "-f",
"CSV"
});
Path csvPath = tmpFolder.resolve(fs.getPath("spreadsheet.csv"));
assertTrue(csvPath.toFile().exists());
assertArrayEquals(expectedCsv.getBytes(), Files.readAllBytes(csvPath));
}
示例3: main
import java.nio.file.FileSystems; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
FileSystem fs = FileSystems.getDefault();
if (fs.getClass().getModule() == Object.class.getModule())
throw new RuntimeException("FileSystemProvider not overridden");
// exercise the file system
Path dir = Files.createTempDirectory("tmp");
if (dir.getFileSystem() != fs)
throw new RuntimeException("'dir' not in default file system");
System.out.println("created: " + dir);
Path foo = Files.createFile(dir.resolve("foo"));
if (foo.getFileSystem() != fs)
throw new RuntimeException("'foo' not in default file system");
System.out.println("created: " + foo);
// exercise interop with java.io.File
File file = foo.toFile();
Path path = file.toPath();
if (path.getFileSystem() != fs)
throw new RuntimeException("'path' not in default file system");
if (!path.equals(foo))
throw new RuntimeException(path + " not equal to " + foo);
}
示例4: getLauncher
import java.nio.file.FileSystems; //导入方法依赖的package包/类
private static String[] getLauncher() throws IOException {
String platform = getPlatform();
if (platform == null) {
return null;
}
String launcher = TEST_SRC + File.separator + platform + "-" + ARCH +
File.separator + "launcher";
final FileSystem FS = FileSystems.getDefault();
Path launcherPath = FS.getPath(launcher);
final boolean hasLauncher = Files.isRegularFile(launcherPath, LinkOption.NOFOLLOW_LINKS)&&
Files.isReadable(launcherPath);
if (!hasLauncher) {
System.out.println("Launcher [" + launcher + "] does not exist. Skipping the test.");
return null;
}
// It is impossible to store an executable file in the source control
// We need to copy the launcher to the working directory
// and set the executable flag
Path localLauncherPath = FS.getPath(WORK_DIR, "launcher");
Files.copy(launcherPath, localLauncherPath,
StandardCopyOption.REPLACE_EXISTING);
if (!Files.isExecutable(localLauncherPath)) {
Set<PosixFilePermission> perms = new HashSet<>(
Files.getPosixFilePermissions(
localLauncherPath,
LinkOption.NOFOLLOW_LINKS
)
);
perms.add(PosixFilePermission.OWNER_EXECUTE);
Files.setPosixFilePermissions(localLauncherPath, perms);
}
return new String[] {launcher, localLauncherPath.toAbsolutePath().toString()};
}
示例5: addPattern
import java.nio.file.FileSystems; //导入方法依赖的package包/类
private static void addPattern(final String fileNameGlobPattern, final List<PathMatcher> matchers) {
if (fileNameGlobPattern.contains("/")) {
throw new IllegalArgumentException("cannot contain '/'");
}
final FileSystem fs = FileSystems.getDefault();
final PathMatcher matcher = fs.getPathMatcher(GLOB_SYNTAX + fileNameGlobPattern);
matchers.add(matcher);
}
示例6: include
import java.nio.file.FileSystems; //导入方法依赖的package包/类
public void include(final String osNameGlobPattern) {
if (osNameGlobPattern.contains("/")) {
throw new IllegalArgumentException("OS name pattern cannot contain '/'");
}
final FileSystem fs = FileSystems.getDefault();
final PathMatcher includeOsNames = fs.getPathMatcher(GLOB_SYNTAX + osNameGlobPattern);
included.add(includeOsNames);
}
示例7: ExplodedImage
import java.nio.file.FileSystems; //导入方法依赖的package包/类
ExplodedImage(Path modulesDir) throws IOException {
defaultFS = FileSystems.getDefault();
String str = defaultFS.getSeparator();
separator = str.equals("/") ? null : str;
modulesDirAttrs = Files.readAttributes(modulesDir, BasicFileAttributes.class);
initNodes();
}
示例8: openAndCloseWatcher
import java.nio.file.FileSystems; //导入方法依赖的package包/类
private static void openAndCloseWatcher(Path dir) {
FileSystem fs = FileSystems.getDefault();
for (int i = 0; i < ITERATIONS_COUNT; i++) {
try (WatchService watcher = fs.newWatchService()) {
dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
} catch (IOException ioe) {
// ignore
}
}
}
示例9: createInterceptor
import java.nio.file.FileSystems; //导入方法依赖的package包/类
@Override
public MutationInterceptor createInterceptor(InterceptorParameters params) {
return new MutantExportInterceptor(FileSystems.getDefault(), params.source(), params.data().getReportDir());
}
示例10: DirectoryReader
import java.nio.file.FileSystems; //导入方法依赖的package包/类
DirectoryReader(Path path) throws IOException {
this(FileSystems.getDefault(), path);
}
示例11: GlobPathSet
import java.nio.file.FileSystems; //导入方法依赖的package包/类
public GlobPathSet(final String rootPathString, final String pattern, final FileTreeWalker fileTreeWalker) {
this(rootPathString, pattern, fileTreeWalker, FileSystems.getDefault());
}
示例12: SinglePathSet
import java.nio.file.FileSystems; //导入方法依赖的package包/类
public SinglePathSet(final String path) {
this(path, FileSystems.getDefault());
}
示例13: findAllTests
import java.nio.file.FileSystems; //导入方法依赖的package包/类
static <T> void findAllTests(final List<T> tests, final Set<String> orphans, final TestFactory<T> testFactory) throws Exception {
final String framework = System.getProperty(TEST_JS_FRAMEWORK);
final String testList = System.getProperty(TEST_JS_LIST);
final String failedTestFileName = System.getProperty(TEST_FAILED_LIST_FILE);
if (failedTestFileName != null) {
final File failedTestFile = new File(failedTestFileName);
if (failedTestFile.exists() && failedTestFile.length() > 0L) {
try (final BufferedReader r = new BufferedReader(new FileReader(failedTestFile))) {
for (;;) {
final String testFileName = r.readLine();
if (testFileName == null) {
break;
}
handleOneTest(framework, new File(testFileName).toPath(), tests, orphans, testFactory);
}
}
return;
}
}
if (testList == null || testList.length() == 0) {
// Run the tests under the test roots dir, selected by the
// TEST_JS_INCLUDES patterns
final String testRootsString = System.getProperty(TEST_JS_ROOTS, "test/script");
if (testRootsString == null || testRootsString.length() == 0) {
throw new Exception("Error: " + TEST_JS_ROOTS + " must be set");
}
final String testRoots[] = testRootsString.split(" ");
final FileSystem fileSystem = FileSystems.getDefault();
final Set<String> testExcludeSet = getExcludeSet();
final Path[] excludePaths = getExcludeDirs();
for (final String root : testRoots) {
final Path dir = fileSystem.getPath(root);
findTests(framework, dir, tests, orphans, excludePaths, testExcludeSet, testFactory);
}
} else {
// TEST_JS_LIST contains a blank speparated list of test file names.
final String strArray[] = testList.split(" ");
for (final String ss : strArray) {
handleOneTest(framework, new File(ss).toPath(), tests, orphans, testFactory);
}
}
}
示例14: fileSystem
import java.nio.file.FileSystems; //导入方法依赖的package包/类
@Override
public FileSystem fileSystem() {
return FileSystems.getDefault();
}
示例15: main
import java.nio.file.FileSystems; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
if (args.length < 1) {
System.err.println("Usage: <picturesRootFolder> [cacheFolder] [configFolder]");
System.exit(-1);
}
FileSystem fileSystem = FileSystems.getDefault();
Path rootFolder = getRootFolder(fileSystem, args[0]);
String cacheRootFolder = (args.length >= 2 ? args[1] : "cache");
String thumbnailCacheFolder = cacheRootFolder + "/thumbnails";
String fullscreenCacheFolder = cacheRootFolder + "/fullscreen";
String extractedPicturesCacheFolder = cacheRootFolder + "/extracted";
String configFile = (args.length >= 3 ? args[2] : ".") + "/photato.ini";
PhotatoConfig.init(configFile);
System.out.println("Starting photato");
System.out.println("-- Config file: " + configFile);
System.out.println("-- Cache folder: " + cacheRootFolder);
System.out.println("-- Pictures folder: " + rootFolder);
HttpServer server = getDefaultServer(fileSystem.getPath("www"));
server.start();
if (!Files.exists(fileSystem.getPath("cache"))) {
Files.createDirectory(fileSystem.getPath("cache"));
}
HttpClient httpClient = HttpClientBuilder.create().setUserAgent(serverName).build();
ExifToolDownloader.run(httpClient, fileSystem, PhotatoConfig.forceFfmpegToolsDownload);
FfmpegDownloader.run(httpClient, fileSystem, PhotatoConfig.forceExifToolsDownload);
ThumbnailGenerator thumbnailGenerator = new ThumbnailGenerator(fileSystem, rootFolder, thumbnailCacheFolder, extractedPicturesCacheFolder, PhotatoConfig.thumbnailHeight, PhotatoConfig.thumbnailQuality);
IGpsCoordinatesDescriptionGetter gpsCoordinatesDescriptionGetter = new OSMGpsCoordinatesDescriptionGetter(httpClient, PhotatoConfig.addressElementsCount);
MetadataAggregator metadataGetter = new MetadataAggregator(fileSystem, "cache/metadata.cache", gpsCoordinatesDescriptionGetter);
FullScreenImageGetter fullScreenImageGetter = new FullScreenImageGetter(fileSystem, rootFolder, fullscreenCacheFolder, extractedPicturesCacheFolder, PhotatoConfig.fullScreenPictureQuality, PhotatoConfig.maxFullScreenPictureWitdh, PhotatoConfig.maxFullScreenPictureHeight);
PhotatoFilesManager photatoFilesManager = new PhotatoFilesManager(rootFolder, fileSystem, metadataGetter, thumbnailGenerator, fullScreenImageGetter, PhotatoConfig.prefixModeOnly, PhotatoConfig.indexFolderName, PhotatoConfig.useParallelPicturesGeneration);
// Closing tmp server
server.shutdown(5, TimeUnit.SECONDS);
while (true) {
try {
server = ServerBootstrap.bootstrap()
.setListenerPort(PhotatoConfig.serverPort)
.setServerInfo(serverName)
.setSocketConfig(getSocketConfig())
.setExceptionLogger(new StdErrorExceptionLogger())
.registerHandler(Routes.rawVideosRootUrl + "/*", new VideoHandler(rootFolder, Routes.rawVideosRootUrl))
.registerHandler(Routes.rawPicturesRootUrl + "/*", new ImageHandler(rootFolder, Routes.rawPicturesRootUrl))
.registerHandler(Routes.fullScreenPicturesRootUrl + "/*", new ImageHandler(fileSystem.getPath(fullscreenCacheFolder), Routes.fullScreenPicturesRootUrl))
.registerHandler(Routes.thumbnailRootUrl + "/*", new ImageHandler(fileSystem.getPath(thumbnailCacheFolder), Routes.thumbnailRootUrl))
.registerHandler(Routes.listItemsApiUrl, new FolderListHandler(Routes.listItemsApiUrl, photatoFilesManager))
.registerHandler("/img/*", new ImageHandler(fileSystem.getPath("www/img"), "/img"))
.registerHandler("/js/*", new JsHandler(fileSystem.getPath("www/js"), "/js"))
.registerHandler("/css/*", new CssHandler(fileSystem.getPath("www/css"), "/css"))
.registerHandler("*", new DefaultHandler(fileSystem.getPath("www")))
.create();
server.start();
System.out.println("Server started on port " + server.getLocalPort() + " (http://" + getLocalIp() + ":" + server.getLocalPort() + ")");
server.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
} catch (IOException | InterruptedException ex) {
// In case of port already binded
System.err.println("Could not start the server ...");
Thread.sleep(1000);
}
}
}