文件转换InputStream
/**
* 文件转换InputStream
*
* @param file
* @return
* @throws FileNotFoundException
*/
public InputStream getInputStream(File file) throws FileNotFoundException {
return new FileInputStream(file);
}
inputStream 转file
/**
* inputStream 转file
*
* @param is
* 输入流
* @param file
* 输出的文件
* @throws IOException
*/
public void getFile(InputStream is, File file) throws IOException {
OutputStream os = null;
try {
os = new FileOutputStream(file);
int len = 0;
byte[] buffer = new byte[8192];
while ((len = is.read(buffer)) != -1) {
os.write(buffer, 0, len);
}
} finally {
is.close();
os.close();
}
}