本文整理汇总了Java中org.apache.cordova.file.EncodingException类的典型用法代码示例。如果您正苦于以下问题:Java EncodingException类的具体用法?Java EncodingException怎么用?Java EncodingException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EncodingException类属于org.apache.cordova.file包,在下文中一共展示了EncodingException类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFile
import org.apache.cordova.file.EncodingException; //导入依赖的package包/类
private JSONObject getFile(String paramString1, String paramString2, JSONObject paramJSONObject, boolean paramBoolean)
throws FileExistsException, IOException, TypeMismatchException, EncodingException, JSONException
{
boolean bool1 = false;
boolean bool2 = false;
if (paramJSONObject != null)
{
bool1 = paramJSONObject.optBoolean("create");
bool2 = false;
if (bool1)
bool2 = paramJSONObject.optBoolean("exclusive");
}
if (paramString2.contains(":"))
throw new EncodingException("This file has a : in it's name");
File localFile = createFileObject(paramString1, paramString2);
if (bool1)
{
if ((bool2) && (localFile.exists()))
throw new FileExistsException("create/exclusive fails");
if (paramBoolean)
localFile.mkdir();
while (!localFile.exists())
{
throw new FileExistsException("create fails");
localFile.createNewFile();
}
}
if (!localFile.exists())
throw new FileNotFoundException("path does not exist");
if (paramBoolean)
{
if (localFile.isFile())
throw new TypeMismatchException("path doesn't exist or is file");
}
else if (localFile.isDirectory())
throw new TypeMismatchException("path doesn't exist or is directory");
return getEntry(localFile);
}
示例2: transferTo
import org.apache.cordova.file.EncodingException; //导入依赖的package包/类
private JSONObject transferTo(String paramString1, String paramString2, String paramString3, boolean paramBoolean)
throws JSONException, NoModificationAllowedException, IOException, InvalidModificationException, EncodingException, FileExistsException
{
String str1 = FileHelper.getRealPath(paramString1, this.cordova);
String str2 = FileHelper.getRealPath(paramString2, this.cordova);
if ((paramString3 != null) && (paramString3.contains(":")))
throw new EncodingException("Bad file name");
File localFile1 = new File(str1);
if (!localFile1.exists())
throw new FileNotFoundException("The source does not exist");
File localFile2 = new File(str2);
if (!localFile2.exists())
throw new FileNotFoundException("The source does not exist");
File localFile3 = createDestination(paramString3, localFile1, localFile2);
if (localFile1.getAbsolutePath().equals(localFile3.getAbsolutePath()))
throw new InvalidModificationException("Can't copy a file onto itself");
JSONObject localJSONObject;
if (localFile1.isDirectory())
if (paramBoolean)
localJSONObject = moveDirectory(localFile1, localFile3);
while (true)
{
return localJSONObject;
return copyDirectory(localFile1, localFile3);
if (!paramBoolean)
break;
localJSONObject = moveFile(localFile1, localFile3);
if (!paramString1.startsWith("content://"))
continue;
notifyDelete(paramString1);
return localJSONObject;
}
return copyFile(localFile1, localFile3);
}
示例3: transferTo
import org.apache.cordova.file.EncodingException; //导入依赖的package包/类
/**
* A setup method that handles the move/copy of files/directories
*
* @param fileName to be copied/moved
* @param newParent is the location where the file will be copied/moved to
* @param newName for the file directory to be called, if null use existing file name
* @param move if false do a copy, if true do a move
* @return a Entry object
* @throws NoModificationAllowedException
* @throws IOException
* @throws InvalidModificationException
* @throws EncodingException
* @throws JSONException
* @throws FileExistsException
*/
private JSONObject transferTo(String fileName, String newParent, String newName, boolean move) throws JSONException, NoModificationAllowedException, IOException, InvalidModificationException, EncodingException, FileExistsException {
String newFileName = FileHelper.getRealPath(fileName, cordova);
newParent = FileHelper.getRealPath(newParent, cordova);
// Check for invalid file name
if (newName != null && newName.contains(":")) {
throw new EncodingException("Bad file name");
}
File source = new File(newFileName);
if (!source.exists()) {
// The file/directory we are copying doesn't exist so we should fail.
throw new FileNotFoundException("The source does not exist");
}
File destinationDir = new File(newParent);
if (!destinationDir.exists()) {
// The destination does not exist so we should fail.
throw new FileNotFoundException("The source does not exist");
}
// Figure out where we should be copying to
File destination = createDestination(newName, source, destinationDir);
//Log.d(LOG_TAG, "Source: " + source.getAbsolutePath());
//Log.d(LOG_TAG, "Destin: " + destination.getAbsolutePath());
// Check to see if source and destination are the same file
if (source.getAbsolutePath().equals(destination.getAbsolutePath())) {
throw new InvalidModificationException("Can't copy a file onto itself");
}
if (source.isDirectory()) {
if (move) {
return moveDirectory(source, destination);
} else {
return copyDirectory(source, destination);
}
} else {
if (move) {
JSONObject newFileEntry = moveFile(source, destination);
// If we've moved a file given its content URI, we need to clean up.
if (fileName.startsWith("content://")) {
notifyDelete(fileName);
}
return newFileEntry;
} else {
return copyFile(source, destination);
}
}
}
示例4: getFile
import org.apache.cordova.file.EncodingException; //导入依赖的package包/类
/**
* Creates or looks up a file.
*
* @param dirPath base directory
* @param fileName 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 dirPath, String fileName, JSONObject options, boolean directory) throws FileExistsException, IOException, TypeMismatchException, EncodingException, JSONException {
boolean create = false;
boolean exclusive = false;
if (options != null) {
create = options.optBoolean("create");
if (create) {
exclusive = options.optBoolean("exclusive");
}
}
// Check for a ":" character in the file to line up with BB and iOS
if (fileName.contains(":")) {
throw new EncodingException("This file has a : in it's name");
}
File fp = createFileObject(dirPath, fileName);
if (create) {
if (exclusive && fp.exists()) {
throw new FileExistsException("create/exclusive fails");
}
if (directory) {
fp.mkdir();
} else {
fp.createNewFile();
}
if (!fp.exists()) {
throw new FileExistsException("create fails");
}
}
else {
if (!fp.exists()) {
throw new FileNotFoundException("path does not exist");
}
if (directory) {
if (fp.isFile()) {
throw new TypeMismatchException("path doesn't exist or is file");
}
} else {
if (fp.isDirectory()) {
throw new TypeMismatchException("path doesn't exist or is directory");
}
}
}
// Return the directory
return getEntry(fp);
}