use of java.nio.file.FileSystemNotFoundException in project ballerina by ballerina-lang.
the class BallerinaDocUtils method copyResources.
/**
* Find a given resource and copy its content recursively to a given target path.
* @param resource name of the resource
* @param targetPath target directory path as a string.
* @throws IOException Failure to load the resources.
*/
public static void copyResources(String resource, String targetPath) throws IOException {
URI uri = null;
try {
// load the resource from the Class path
uri = BallerinaDocUtils.class.getClassLoader().getResource(resource).toURI();
} catch (URISyntaxException e) {
throw new IOException("Failed to load resources: " + e.getMessage(), e);
}
Path source;
try {
source = Paths.get(uri);
} catch (FileSystemNotFoundException e) {
// this means the resource is in a jar file, hence we have to create a new File system for the jar
Map<String, String> env = new HashMap<>();
env.put("create", "true");
FileSystems.newFileSystem(uri, env);
source = Paths.get(uri);
}
Path target = Paths.get(targetPath, resource);
Files.walkFileTree(source, new RecursiveFileVisitor(source, target));
}
use of java.nio.file.FileSystemNotFoundException in project jimfs by google.
the class JimfsFileSystemCloseTest method testIsNotAvailableFromProvider.
@Test
public void testIsNotAvailableFromProvider() throws IOException {
URI uri = fs.getUri();
assertEquals(fs, FileSystems.getFileSystem(uri));
fs.close();
try {
FileSystems.getFileSystem(uri);
fail();
} catch (FileSystemNotFoundException expected) {
}
}
use of java.nio.file.FileSystemNotFoundException in project j2objc by google.
the class FileSystemNotFoundExceptionTest method test_constructor_empty.
public void test_constructor_empty() {
FileSystemNotFoundException exception = new FileSystemNotFoundException();
assertEquals(null, exception.getMessage());
}
use of java.nio.file.FileSystemNotFoundException in project j2objc by google.
the class FileSystemNotFoundExceptionTest method test_constructor$String.
public void test_constructor$String() {
String message = "message";
FileSystemNotFoundException exception = new FileSystemNotFoundException(message);
assertEquals(message, exception.getMessage());
}
use of java.nio.file.FileSystemNotFoundException in project mycore by MyCoRe-Org.
the class MCRPaths method getPath.
static Path getPath(String scheme, String owner, String path) {
URI uri;
try {
uri = getURI(scheme, owner, path);
LogManager.getLogger(MCRPaths.class).debug("Generated path URI:{}", uri);
} catch (URISyntaxException e) {
throw new InvalidPathException(path, "URI syntax error (" + e.getMessage() + ") for path");
}
try {
return Paths.get(uri);
} catch (FileSystemNotFoundException e) {
for (FileSystemProvider provider : webAppProvider) {
if (provider.getScheme().equals(uri.getScheme())) {
return provider.getPath(uri);
}
}
throw e;
}
}
Aggregations