mirror of
https://gitee.com/dromara/hutool.git
synced 2025-06-28 13:34:09 +08:00
根据JDK-8080225修改了部分新建文件输入流和文件输出流的创建方式
This commit is contained in:
parent
46b9633768
commit
f5cb27a608
@ -8,6 +8,7 @@
|
|||||||
### 🐣新特性
|
### 🐣新特性
|
||||||
* 【core 】 PhoneUtil.isTel400800支持400-XXX-XXXX格式(issue#2929@Github)
|
* 【core 】 PhoneUtil.isTel400800支持400-XXX-XXXX格式(issue#2929@Github)
|
||||||
* 【core 】 build(pom): 添加 Automatic-Module-Name属性(pr#2926@Github)
|
* 【core 】 build(pom): 添加 Automatic-Module-Name属性(pr#2926@Github)
|
||||||
|
* 【core 】 根据JDK-8080225修改了部分新建文件输入流和文件输出流的创建方式(pr#2930@Github)
|
||||||
|
|
||||||
### 🐞Bug修复
|
### 🐞Bug修复
|
||||||
* 【db 】 修复识别JDBC驱动时重复问题(pr#940@Gitee)
|
* 【db 】 修复识别JDBC驱动时重复问题(pr#940@Gitee)
|
||||||
|
@ -5,9 +5,10 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.awt.image.DataBufferByte;
|
import java.awt.image.DataBufferByte;
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 动态GIF动画生成器,可生成一个或多个帧的GIF。
|
* 动态GIF动画生成器,可生成一个或多个帧的GIF。
|
||||||
@ -296,7 +297,7 @@ public class AnimatedGifEncoder {
|
|||||||
public boolean start(String file) {
|
public boolean start(String file) {
|
||||||
boolean ok;
|
boolean ok;
|
||||||
try {
|
try {
|
||||||
out = new BufferedOutputStream(new FileOutputStream(file));
|
out = new BufferedOutputStream(Files.newOutputStream(Paths.get(file)));
|
||||||
ok = start(out);
|
ok = start(out);
|
||||||
closeStream = true;
|
closeStream = true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -10,10 +10,11 @@ import java.awt.Rectangle;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.awt.image.DataBufferInt;
|
import java.awt.image.DataBufferInt;
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -339,7 +340,7 @@ public class GifDecoder {
|
|||||||
URL url = new URL(name);
|
URL url = new URL(name);
|
||||||
in = new BufferedInputStream(url.openStream());
|
in = new BufferedInputStream(url.openStream());
|
||||||
} else {
|
} else {
|
||||||
in = new BufferedInputStream(new FileInputStream(name));
|
in = new BufferedInputStream(Files.newInputStream(Paths.get(name)));
|
||||||
}
|
}
|
||||||
status = read(in);
|
status = read(in);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -29,9 +29,7 @@ import java.io.BufferedReader;
|
|||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileFilter;
|
import java.io.FileFilter;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.LineNumberReader;
|
import java.io.LineNumberReader;
|
||||||
@ -1917,7 +1915,7 @@ public class FileUtil extends PathUtil {
|
|||||||
*/
|
*/
|
||||||
public static BOMInputStream getBOMInputStream(File file) throws IORuntimeException {
|
public static BOMInputStream getBOMInputStream(File file) throws IORuntimeException {
|
||||||
try {
|
try {
|
||||||
return new BOMInputStream(new FileInputStream(file));
|
return new BOMInputStream(Files.newInputStream(file.toPath()));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IORuntimeException(e);
|
throw new IORuntimeException(e);
|
||||||
}
|
}
|
||||||
@ -2561,8 +2559,8 @@ public class FileUtil extends PathUtil {
|
|||||||
public static BufferedOutputStream getOutputStream(File file) throws IORuntimeException {
|
public static BufferedOutputStream getOutputStream(File file) throws IORuntimeException {
|
||||||
final OutputStream out;
|
final OutputStream out;
|
||||||
try {
|
try {
|
||||||
out = new FileOutputStream(touch(file));
|
out = Files.newOutputStream(touch(file).toPath());
|
||||||
} catch (IOException e) {
|
} catch (final IOException e) {
|
||||||
throw new IORuntimeException(e);
|
throw new IORuntimeException(e);
|
||||||
}
|
}
|
||||||
return IoUtil.toBuffered(out);
|
return IoUtil.toBuffered(out);
|
||||||
@ -3337,8 +3335,8 @@ public class FileUtil extends PathUtil {
|
|||||||
throw new IllegalArgumentException("Checksums can't be computed on directories");
|
throw new IllegalArgumentException("Checksums can't be computed on directories");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return IoUtil.checksum(new FileInputStream(file), checksum);
|
return IoUtil.checksum(Files.newInputStream(file.toPath()), checksum);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (IOException e) {
|
||||||
throw new IORuntimeException(e);
|
throw new IORuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,11 @@ import java.io.File;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
@ -336,11 +338,11 @@ public class FileWriter extends FileWrapper {
|
|||||||
* @since 5.5.2
|
* @since 5.5.2
|
||||||
*/
|
*/
|
||||||
public File writeFromStream(InputStream in, boolean isCloseIn) throws IORuntimeException {
|
public File writeFromStream(InputStream in, boolean isCloseIn) throws IORuntimeException {
|
||||||
FileOutputStream out = null;
|
OutputStream out = null;
|
||||||
try {
|
try {
|
||||||
out = new FileOutputStream(FileUtil.touch(file));
|
out = Files.newOutputStream(FileUtil.touch(file).toPath());
|
||||||
IoUtil.copy(in, out);
|
IoUtil.copy(in, out);
|
||||||
} catch (IOException e) {
|
} catch (final IOException e) {
|
||||||
throw new IORuntimeException(e);
|
throw new IORuntimeException(e);
|
||||||
} finally {
|
} finally {
|
||||||
IoUtil.close(out);
|
IoUtil.close(out);
|
||||||
@ -359,7 +361,7 @@ public class FileWriter extends FileWrapper {
|
|||||||
*/
|
*/
|
||||||
public BufferedOutputStream getOutputStream() throws IORuntimeException {
|
public BufferedOutputStream getOutputStream() throws IORuntimeException {
|
||||||
try {
|
try {
|
||||||
return new BufferedOutputStream(new FileOutputStream(FileUtil.touch(file)));
|
return new BufferedOutputStream(Files.newOutputStream(FileUtil.touch(file).toPath()));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IORuntimeException(e);
|
throw new IORuntimeException(e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user