mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
FileUtil和PathUtil增加Resource重载
This commit is contained in:
parent
21bf415eab
commit
65ec4cf3aa
@ -1058,7 +1058,7 @@ public class FileUtil extends PathUtil {
|
|||||||
/**
|
/**
|
||||||
* 通过JDK7+的 Files#copy(InputStream, Path, CopyOption...) 方法拷贝文件
|
* 通过JDK7+的 Files#copy(InputStream, Path, CopyOption...) 方法拷贝文件
|
||||||
*
|
*
|
||||||
* @param src 源文件
|
* @param src 源文件流,使用后不关闭
|
||||||
* @param dest 目标文件或目录,如果为目录使用与源文件相同的文件名
|
* @param dest 目标文件或目录,如果为目录使用与源文件相同的文件名
|
||||||
* @param options {@link StandardCopyOption}
|
* @param options {@link StandardCopyOption}
|
||||||
* @return 目标文件
|
* @return 目标文件
|
||||||
|
@ -196,13 +196,17 @@ public class PathUtil {
|
|||||||
if(src instanceof FileResource){
|
if(src instanceof FileResource){
|
||||||
return copyFile(((FileResource) src).getFile().toPath(), target, options);
|
return copyFile(((FileResource) src).getFile().toPath(), target, options);
|
||||||
}
|
}
|
||||||
return copyFile(src.getStream(), target, options);
|
try(InputStream stream = src.getStream()){
|
||||||
|
return copyFile(stream, target, options);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过JDK7+的 {@link Files#copy(InputStream, Path, CopyOption...)} 方法拷贝文件
|
* 通过JDK7+的 {@link Files#copy(InputStream, Path, CopyOption...)} 方法拷贝文件
|
||||||
*
|
*
|
||||||
* @param src 源文件流
|
* @param src 源文件流,使用后不闭流
|
||||||
* @param target 目标文件或目录,如果为目录使用与源文件相同的文件名
|
* @param target 目标文件或目录,如果为目录使用与源文件相同的文件名
|
||||||
* @param options {@link StandardCopyOption}
|
* @param options {@link StandardCopyOption}
|
||||||
* @return 目标Path
|
* @return 目标Path
|
||||||
|
Loading…
x
Reference in New Issue
Block a user