+ inputStreamToFile fixed.
This commit is contained in:
parent
cfba114331
commit
289de88b69
@ -144,12 +144,14 @@ public class FileUtils {
|
|||||||
* @param file 文件
|
* @param file 文件
|
||||||
*/
|
*/
|
||||||
public static void inputStreamToFile(InputStream inputStream, File file) {
|
public static void inputStreamToFile(InputStream inputStream, File file) {
|
||||||
try {
|
try (FileOutputStream fos = new FileOutputStream(file) ; BufferedOutputStream bos = new BufferedOutputStream(fos)) {
|
||||||
String text = new String(IO.readFully(inputStream), Charset.forName("utf-8"));
|
byte[] buf = new byte[1024];
|
||||||
FileWriter fileWriter = new FileWriter(FileUtils.createNewFile(file));
|
int len;
|
||||||
fileWriter.write(text);
|
while((len = inputStream.read(buf)) > 0) {
|
||||||
fileWriter.close();
|
bos.write(buf, 0, len);
|
||||||
} catch (IOException ignored) {
|
}
|
||||||
|
bos.flush();
|
||||||
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user