本文整理汇总了Java中sun.plugin.dom.exception.InvalidStateException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidStateException类的具体用法?Java InvalidStateException怎么用?Java InvalidStateException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InvalidStateException类属于sun.plugin.dom.exception包,在下文中一共展示了InvalidStateException类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveResource
import sun.plugin.dom.exception.InvalidStateException; //导入依赖的package包/类
/**
* Copies the file from java resources to the output path.
* Returns the created file.
*
* @param file File name to copy
* @param outputPath Output
* @param replace If {@code true}, replaces the existing file.
* @return the created file.
*/
public static Validation<Exception, File> saveResource(String file, String outputPath, boolean replace)
{
ClassLoader loader = FileUtil.class.getClassLoader();
URL url = loader.getResource(file);
if (url == null)
return new Failure<>(new FileNotFoundException(file));
try {
URLConnection connection = url.openConnection();
connection.setUseCaches(false);
File outFile = new File(outputPath);
if (outFile.exists())
if (!replace)
return new Success<>(outFile);
else if (!outFile.delete())
return new Failure<>(new InvalidStateException("Could not override existing file."));
Files.copy(connection.getInputStream(), outFile.toPath());
return new Success<>(outFile);
} catch (Exception e) {
return new Failure<>(e);
}
}
示例2: getResult
import sun.plugin.dom.exception.InvalidStateException; //导入依赖的package包/类
public Item getResult(){
char[][] currentTable = compute();
for (Item entry : Constants.itemTypes.values()) {
if (entry.template.compare(currentTable)) {
return entry;
}
}
throw new InvalidStateException("No result");
}