本文整理匯總了Java中java.net.MalformedURLException.initCause方法的典型用法代碼示例。如果您正苦於以下問題:Java MalformedURLException.initCause方法的具體用法?Java MalformedURLException.initCause怎麽用?Java MalformedURLException.initCause使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.net.MalformedURLException
的用法示例。
在下文中一共展示了MalformedURLException.initCause方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: remove
import java.net.MalformedURLException; //導入方法依賴的package包/類
/**
* Deletes a file or directory. It is an error to attempt to delete a directory that is not empty.
* It is an error to attempt to delete the root directory of a filesystem.
*
* @return a boolean representing success of failure
* @throws NoModificationAllowedException
* @throws InvalidModificationException
* @throws MalformedURLException
*/
private boolean remove(String baseURLstr) throws NoModificationAllowedException, InvalidModificationException, MalformedURLException {
try {
LocalFilesystemURL inputURL = LocalFilesystemURL.parse(baseURLstr);
// You can't delete the root directory.
if ("".equals(inputURL.path) || "/".equals(inputURL.path)) {
throw new NoModificationAllowedException("You can't delete the root directory");
}
Filesystem fs = this.filesystemForURL(inputURL);
if (fs == null) {
throw new MalformedURLException("No installed handlers for this URL");
}
return fs.removeFileAtLocalURL(inputURL);
} catch (IllegalArgumentException e) {
MalformedURLException mue = new MalformedURLException("Unrecognized filesystem URL");
mue.initCause(e);
throw mue;
}
}
示例2: getParent
import java.net.MalformedURLException; //導入方法依賴的package包/類
/**
* Look up the parent DirectoryEntry containing this Entry.
* If this Entry is the root of its filesystem, its parent is itself.
*/
private JSONObject getParent(String baseURLstr) throws JSONException, IOException {
try {
LocalFilesystemURL inputURL = LocalFilesystemURL.parse(baseURLstr);
Filesystem fs = this.filesystemForURL(inputURL);
if (fs == null) {
throw new MalformedURLException("No installed handlers for this URL");
}
return fs.getParentForLocalURL(inputURL);
} catch (IllegalArgumentException e) {
MalformedURLException mue = new MalformedURLException("Unrecognized filesystem URL");
mue.initCause(e);
throw mue;
}
}
示例3: truncateFile
import java.net.MalformedURLException; //導入方法依賴的package包/類
/**
* Truncate the file to size
*/
private long truncateFile(String srcURLstr, long size) throws FileNotFoundException, IOException, NoModificationAllowedException {
try {
LocalFilesystemURL inputURL = LocalFilesystemURL.parse(srcURLstr);
Filesystem fs = this.filesystemForURL(inputURL);
if (fs == null) {
throw new MalformedURLException("No installed handlers for this URL");
}
return fs.truncateFileAtURL(inputURL, size);
} catch (IllegalArgumentException e) {
MalformedURLException mue = new MalformedURLException("Unrecognized filesystem URL");
mue.initCause(e);
throw mue;
}
}
示例4: readEntries
import java.net.MalformedURLException; //導入方法依賴的package包/類
/**
* Read the list of files from this directory.
*
* @return a JSONArray containing JSONObjects that represent Entry objects.
* @throws FileNotFoundException if the directory is not found.
* @throws JSONException
* @throws MalformedURLException
*/
private JSONArray readEntries(String baseURLstr) throws FileNotFoundException, JSONException, MalformedURLException {
try {
LocalFilesystemURL inputURL = LocalFilesystemURL.parse(baseURLstr);
Filesystem fs = this.filesystemForURL(inputURL);
if (fs == null) {
throw new MalformedURLException("No installed handlers for this URL");
}
return fs.readEntriesAtLocalURL(inputURL);
} catch (IllegalArgumentException e) {
MalformedURLException mue = new MalformedURLException("Unrecognized filesystem URL");
mue.initCause(e);
throw mue;
}
}
示例5: getFileMetadata
import java.net.MalformedURLException; //導入方法依賴的package包/類
/**
* Returns a File that represents the current state of the file that this FileEntry represents.
*
* @return returns a JSONObject represent a W3C File object
*/
private JSONObject getFileMetadata(String baseURLstr) throws FileNotFoundException, JSONException, MalformedURLException {
try {
LocalFilesystemURL inputURL = LocalFilesystemURL.parse(baseURLstr);
Filesystem fs = this.filesystemForURL(inputURL);
if (fs == null) {
throw new MalformedURLException("No installed handlers for this URL");
}
return fs.getFileMetadataForLocalURL(inputURL);
} catch (IllegalArgumentException e) {
MalformedURLException mue = new MalformedURLException("Unrecognized filesystem URL");
mue.initCause(e);
throw mue;
}
}
示例6: getFile
import java.net.MalformedURLException; //導入方法依賴的package包/類
/**
* Creates or looks up a file.
*
* @param baseURLstr base directory
* @param path file/directory to lookup or create
* @param options specify whether to create or not
* @param directory if true look up directory, if false look up file
* @return a Entry object
* @throws FileExistsException
* @throws IOException
* @throws TypeMismatchException
* @throws EncodingException
* @throws JSONException
*/
private JSONObject getFile(String baseURLstr, String path, JSONObject options, boolean directory) throws FileExistsException, IOException, TypeMismatchException, EncodingException, JSONException {
try {
LocalFilesystemURL inputURL = LocalFilesystemURL.parse(baseURLstr);
Filesystem fs = this.filesystemForURL(inputURL);
if (fs == null) {
throw new MalformedURLException("No installed handlers for this URL");
}
return fs.getFileForLocalURL(inputURL, path, options, directory);
} catch (IllegalArgumentException e) {
MalformedURLException mue = new MalformedURLException("Unrecognized filesystem URL");
mue.initCause(e);
throw mue;
}
}
示例7: write
import java.net.MalformedURLException; //導入方法依賴的package包/類
/**
* Write contents of file.
*
* @param data The contents of the file.
* @param offset The position to begin writing the file.
* @param isBinary True if the file contents are base64-encoded binary data
*/
/**/
public long write(String srcURLstr, String data, int offset, boolean isBinary) throws FileNotFoundException, IOException, NoModificationAllowedException {
try {
LocalFilesystemURL inputURL = LocalFilesystemURL.parse(srcURLstr);
Filesystem fs = this.filesystemForURL(inputURL);
if (fs == null) {
throw new MalformedURLException("No installed handlers for this URL");
}
long x = fs.writeToFileAtURL(inputURL, data, offset, isBinary); LOG.d("TEST",srcURLstr + ": "+x); return x;
} catch (IllegalArgumentException e) {
MalformedURLException mue = new MalformedURLException("Unrecognized filesystem URL");
mue.initCause(e);
throw mue;
}
}
示例8: removeRecursively
import java.net.MalformedURLException; //導入方法依賴的package包/類
/**
* Deletes a directory and all of its contents, if any. In the event of an error
* [e.g. trying to delete a directory that contains a file that cannot be removed],
* some of the contents of the directory may be deleted.
* It is an error to attempt to delete the root directory of a filesystem.
*
* @return a boolean representing success of failure
* @throws FileExistsException
* @throws NoModificationAllowedException
* @throws MalformedURLException
*/
private boolean removeRecursively(String baseURLstr) throws FileExistsException, NoModificationAllowedException, MalformedURLException {
try {
LocalFilesystemURL inputURL = LocalFilesystemURL.parse(baseURLstr);
// You can't delete the root directory.
if ("".equals(inputURL.path) || "/".equals(inputURL.path)) {
throw new NoModificationAllowedException("You can't delete the root directory");
}
Filesystem fs = this.filesystemForURL(inputURL);
if (fs == null) {
throw new MalformedURLException("No installed handlers for this URL");
}
return fs.recursiveRemoveFileAtLocalURL(inputURL);
} catch (IllegalArgumentException e) {
MalformedURLException mue = new MalformedURLException("Unrecognized filesystem URL");
mue.initCause(e);
throw mue;
}
}
示例9: resolveUrl
import java.net.MalformedURLException; //導入方法依賴的package包/類
/**
* Resolves URL within a root.
* @param root the root to resolve the URL in.
* @param relativePath the relative path under the root.
* @param isDirectory true if the relativePath is known to point to directory,
* false if the relativePath is known to point to file, null if nothing is known
* about the target.
* @return
* @throws MalformedURLException
* @throws IllegalStateException when file ends with '/'
*/
public static URL resolveUrl(
@NonNull final URL root,
@NonNull final String relativePath,
@NullAllowed final Boolean isDirectory) throws MalformedURLException, IllegalStateException {
try {
if ("file".equals(root.getProtocol())) { //NOI18N
if (isDirectory == Boolean.FALSE &&
(relativePath.isEmpty() || relativePath.charAt(relativePath.length()-1) == '/')) { //NOI18N
throw new IllegalStateException(
MessageFormat.format("relativePath: {0}", relativePath)); //NOI18N
}
// Performance optimization for File.toURI() which calls this method
// and the original implementation calls into native method
return BaseUtilities.toURI(new FastFile(
BaseUtilities.toFile(root.toURI()),
relativePath,
isDirectory)).toURL();
} else {
return new URL(root, relativePath);
}
} catch (URISyntaxException use) {
MalformedURLException mue = new MalformedURLException("Can't resolve URL: root=" + root + ", relativePath=" + relativePath); //NOI18N
mue.initCause(use);
throw mue;
}
}
示例10: resolveLocalFileSystemURI
import java.net.MalformedURLException; //導入方法依賴的package包/類
/**
* Allows the user to look up the Entry for a file or directory referred to by a local URI.
*
* @param uriString of the file/directory to look up
* @return a JSONObject representing a Entry from the filesystem
* @throws MalformedURLException if the url is not valid
* @throws FileNotFoundException if the file does not exist
* @throws IOException if the user can't read the file
* @throws JSONException
*/
private JSONObject resolveLocalFileSystemURI(String uriString) throws IOException, JSONException {
if (uriString == null) {
throw new MalformedURLException("Unrecognized filesystem URL");
}
Uri uri = Uri.parse(uriString);
boolean isNativeUri = false;
LocalFilesystemURL inputURL = LocalFilesystemURL.parse(uri);
if (inputURL == null) {
/* Check for file://, content:// urls */
inputURL = resolveNativeUri(uri);
isNativeUri = true;
}
try {
Filesystem fs = this.filesystemForURL(inputURL);
if (fs == null) {
throw new MalformedURLException("No installed handlers for this URL");
}
if (fs.exists(inputURL)) {
if (!isNativeUri) {
// If not already resolved as native URI, resolve to a native URI and back to
// fix the terminating slash based on whether the entry is a directory or file.
inputURL = fs.toLocalUri(fs.toNativeUri(inputURL));
}
return fs.getEntryForLocalURL(inputURL);
}
} catch (IllegalArgumentException e) {
MalformedURLException mue = new MalformedURLException("Unrecognized filesystem URL");
mue.initCause(e);
throw mue;
}
throw new FileNotFoundException();
}