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;
public class IOUtil {
private static final int DEFAULT_BYTE_SIZE = 1024;
private IOUtil(){}
private static void copyFile(String srcPath, String descPath) {
InputStream in = null;
OutputStream out = null;
try {
in = new FileInputStream(new File(srcPath));
byte[] bytes = new byte[DEFAULT_BYTE_SIZE];
out = new FileOutputStream(descPath);
int len = 0;
while((len = in.read(bytes)) != -1){
out.write(bytes, 0, len);
}
} catch (Exception e) {
} finally {
if(in != null){
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if(out != null){
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public static byte[] readFile2Byte(String path){
InputStream in = null;
try {
in = new FileInputStream(new File(path));
byte[] bytes = new byte[in.available()];
int len = 0;
for(int i = 0;(len=in.read())!=-1;i++){
bytes[i] = (byte) ((char)len);
}
return bytes;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if(in != null){
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return null;
}
}