当前位置: 首页>>代码示例>>Java>>正文


Java MalformedURLException.initCause方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:rodrigonsh,项目名称:alerta-fraude,代码行数:31,代码来源:FileUtils.java

示例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;
    }
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:20,代码来源:FileUtils.java

示例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;
    }
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:19,代码来源:FileUtils.java

示例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;
    }
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:24,代码来源:FileUtils.java

示例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;
    }
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:21,代码来源:FileUtils.java

示例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;
    }

}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:31,代码来源:FileUtils.java

示例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;
    }

}
 
开发者ID:alex-shpak,项目名称:keemob,代码行数:25,代码来源:FileUtils.java

示例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;
    }
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:32,代码来源:FileUtils.java

示例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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:Util.java

示例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();
}
 
开发者ID:rodrigonsh,项目名称:alerta-fraude,代码行数:46,代码来源:FileUtils.java


注:本文中的java.net.MalformedURLException.initCause方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。