|
@@ -1,17 +1,12 @@
|
|
package cn.com.qmth.examcloud.core.questions.base;
|
|
package cn.com.qmth.examcloud.core.questions.base;
|
|
|
|
|
|
-import java.io.BufferedInputStream;
|
|
|
|
-import java.io.BufferedOutputStream;
|
|
|
|
-import java.io.DataInputStream;
|
|
|
|
-import java.io.DataOutputStream;
|
|
|
|
-import java.io.File;
|
|
|
|
-import java.io.FileInputStream;
|
|
|
|
-import java.io.FileNotFoundException;
|
|
|
|
-import java.io.FileOutputStream;
|
|
|
|
-import java.io.IOException;
|
|
|
|
-import java.io.InputStream;
|
|
|
|
-import java.io.OutputStream;
|
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
|
+import org.apache.commons.io.IOUtils;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
+
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.io.*;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.URL;
|
|
import java.net.URL;
|
|
import java.net.URLEncoder;
|
|
import java.net.URLEncoder;
|
|
@@ -21,20 +16,11 @@ import java.nio.file.Paths;
|
|
import java.util.zip.ZipEntry;
|
|
import java.util.zip.ZipEntry;
|
|
import java.util.zip.ZipOutputStream;
|
|
import java.util.zip.ZipOutputStream;
|
|
|
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
|
-
|
|
|
|
-import org.apache.commons.io.FileUtils;
|
|
|
|
-import org.apache.commons.io.IOUtils;
|
|
|
|
-import org.apache.commons.lang.StringEscapeUtils;
|
|
|
|
-import org.slf4j.Logger;
|
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
|
-
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author chenken
|
|
* @author chenken
|
|
* @date 2017年7月17日 上午9:36:32
|
|
* @date 2017年7月17日 上午9:36:32
|
|
* @company QMTH
|
|
* @company QMTH
|
|
- * @description FileUtil.java
|
|
|
|
*/
|
|
*/
|
|
public class FileDisposeUtil {
|
|
public class FileDisposeUtil {
|
|
|
|
|
|
@@ -83,7 +69,7 @@ public class FileDisposeUtil {
|
|
dataInputStream = null;
|
|
dataInputStream = null;
|
|
}
|
|
}
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
}
|
|
}
|
|
if (connection != null) {
|
|
if (connection != null) {
|
|
connection.disconnect();
|
|
connection.disconnect();
|
|
@@ -131,9 +117,9 @@ public class FileDisposeUtil {
|
|
out.close();
|
|
out.close();
|
|
in.close();
|
|
in.close();
|
|
} catch (FileNotFoundException e) {
|
|
} catch (FileNotFoundException e) {
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
} finally {
|
|
} finally {
|
|
try {
|
|
try {
|
|
if (null != out) {
|
|
if (null != out) {
|
|
@@ -145,7 +131,7 @@ public class FileDisposeUtil {
|
|
in = null;
|
|
in = null;
|
|
}
|
|
}
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
throw new RuntimeException(e);
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -164,7 +150,7 @@ public class FileDisposeUtil {
|
|
try {
|
|
try {
|
|
type = Files.probeContentType(path);
|
|
type = Files.probeContentType(path);
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
}
|
|
}
|
|
return type;
|
|
return type;
|
|
}
|
|
}
|
|
@@ -220,7 +206,7 @@ public class FileDisposeUtil {
|
|
}
|
|
}
|
|
zos.flush();
|
|
zos.flush();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
} finally {
|
|
} finally {
|
|
IOUtils.closeQuietly(bis);
|
|
IOUtils.closeQuietly(bis);
|
|
IOUtils.closeQuietly(fis);
|
|
IOUtils.closeQuietly(fis);
|
|
@@ -230,7 +216,7 @@ public class FileDisposeUtil {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
} finally {
|
|
} finally {
|
|
IOUtils.closeQuietly(bis);
|
|
IOUtils.closeQuietly(bis);
|
|
IOUtils.closeQuietly(fis);
|
|
IOUtils.closeQuietly(fis);
|