mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-28 22:17:50 +08:00
cleaning up handling of exceptions. removing unnecessary exception declaration in FileUtils. removing try-catch that should not have been done in HttpHandler
This commit is contained in:
parent
7c8db0ea44
commit
cd5bf6195e
@ -531,7 +531,7 @@ public class FileUtils extends Plugin {
|
|||||||
* @throws NoModificationAllowedException
|
* @throws NoModificationAllowedException
|
||||||
* @throws InvalidModificationException
|
* @throws InvalidModificationException
|
||||||
*/
|
*/
|
||||||
private JSONObject moveDirectory(File srcDir, File destinationDir) throws JSONException, FileExistsException, NoModificationAllowedException, InvalidModificationException {
|
private JSONObject moveDirectory(File srcDir, File destinationDir) throws JSONException, InvalidModificationException {
|
||||||
// Renaming a file to an existing directory should fail
|
// Renaming a file to an existing directory should fail
|
||||||
if (destinationDir.exists() && destinationDir.isFile()) {
|
if (destinationDir.exists() && destinationDir.isFile()) {
|
||||||
throw new InvalidModificationException("Can't rename a file to a directory");
|
throw new InvalidModificationException("Can't rename a file to a directory");
|
||||||
|
@ -20,6 +20,7 @@ package com.phonegap;
|
|||||||
|
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
@ -56,14 +57,13 @@ public class HttpHandler {
|
|||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeToDisk(HttpEntity entity, String file) throws EOFException
|
private void writeToDisk(HttpEntity entity, String file) throws IllegalStateException, IOException
|
||||||
/**
|
/**
|
||||||
* writes a HTTP entity to the specified filename and location on disk
|
* writes a HTTP entity to the specified filename and location on disk
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
String FilePath="/sdcard/" + file;
|
String FilePath="/sdcard/" + file;
|
||||||
try {
|
|
||||||
InputStream in = entity.getContent();
|
InputStream in = entity.getContent();
|
||||||
byte buff[] = new byte[1024];
|
byte buff[] = new byte[1024];
|
||||||
FileOutputStream out=
|
FileOutputStream out=
|
||||||
@ -77,6 +77,5 @@ public class HttpHandler {
|
|||||||
} while (true);
|
} while (true);
|
||||||
out.flush();
|
out.flush();
|
||||||
out.close();
|
out.close();
|
||||||
} catch (Exception e) { e.printStackTrace(); }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user