mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-24 18:04:54 +08:00
fix code
This commit is contained in:
parent
28777b69b7
commit
daa618ef3d
@ -32,9 +32,7 @@ import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.LineNumberReader;
|
||||
@ -1790,8 +1788,7 @@ public class FileUtil extends PathUtil {
|
||||
*/
|
||||
public static BOMInputStream getBOMInputStream(final File file) throws IORuntimeException {
|
||||
try {
|
||||
//noinspection IOStreamConstructor
|
||||
return new BOMInputStream(new FileInputStream(file));
|
||||
return new BOMInputStream(Files.newInputStream(file.toPath()));
|
||||
} catch (final IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
}
|
||||
@ -2335,8 +2332,7 @@ public class FileUtil extends PathUtil {
|
||||
public static BufferedOutputStream getOutputStream(final File file) throws IORuntimeException {
|
||||
final OutputStream out;
|
||||
try {
|
||||
//noinspection IOStreamConstructor
|
||||
out = new FileOutputStream(touch(file));
|
||||
out = Files.newOutputStream(touch(file).toPath());
|
||||
} catch (final IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedWriter;
|
||||
@ -13,9 +13,11 @@ import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@ -336,9 +338,9 @@ public class FileWriter extends FileWrapper {
|
||||
* @since 5.5.2
|
||||
*/
|
||||
public File writeFromStream(final InputStream in, final boolean isCloseIn) throws IORuntimeException {
|
||||
FileOutputStream out = null;
|
||||
OutputStream out = null;
|
||||
try {
|
||||
out = new FileOutputStream(FileUtil.touch(file));
|
||||
out = Files.newOutputStream(FileUtil.touch(file).toPath());
|
||||
IoUtil.copy(in, out);
|
||||
} catch (final IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
@ -359,7 +361,7 @@ public class FileWriter extends FileWrapper {
|
||||
*/
|
||||
public BufferedOutputStream getOutputStream() throws IORuntimeException {
|
||||
try {
|
||||
return new BufferedOutputStream(new FileOutputStream(FileUtil.touch(file)));
|
||||
return new BufferedOutputStream(Files.newOutputStream(FileUtil.touch(file).toPath()));
|
||||
} catch (final IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
}
|
||||
|
@ -5,9 +5,10 @@ import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferByte;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
/**
|
||||
* 动态GIF动画生成器,可生成一个或多个帧的GIF。
|
||||
@ -296,8 +297,7 @@ public class AnimatedGifEncoder {
|
||||
public boolean start(final String file) {
|
||||
boolean ok;
|
||||
try {
|
||||
//noinspection IOStreamConstructor
|
||||
out = new BufferedOutputStream(new FileOutputStream(file));
|
||||
out = new BufferedOutputStream(Files.newOutputStream(Paths.get(file)));
|
||||
ok = start(out);
|
||||
closeStream = true;
|
||||
} catch (final IOException e) {
|
||||
|
@ -10,10 +10,11 @@ import java.awt.Rectangle;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
@ -339,7 +340,7 @@ public class GifDecoder {
|
||||
final URL url = new URL(name);
|
||||
in = new BufferedInputStream(url.openStream());
|
||||
} else {
|
||||
in = new BufferedInputStream(new FileInputStream(name));
|
||||
in = new BufferedInputStream(Files.newInputStream(Paths.get(name)));
|
||||
}
|
||||
status = read(in);
|
||||
} catch (final IOException e) {
|
||||
|
Loading…
Reference in New Issue
Block a user