mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -133,7 +133,7 @@ public class SevenZArchiver implements Archiver {
|
||||
* @param filter 文件过滤器,指定哪些文件或目录可以加入,当{@link Predicate#test(Object)}为{@code true}保留,null表示保留全部
|
||||
*/
|
||||
private void addInternal(final File file, final String path, final Predicate<File> filter) throws IOException {
|
||||
if (null != filter && false == filter.test(file)) {
|
||||
if (null != filter && ! filter.test(file)) {
|
||||
return;
|
||||
}
|
||||
final SevenZOutputFile out = this.sevenZOutputFile;
|
||||
|
@@ -168,7 +168,7 @@ public class StreamArchiver implements Archiver {
|
||||
* @param predicate 文件过滤器,指定哪些文件或目录可以加入,当{@link Predicate#test(Object)}为{@code true}加入。
|
||||
*/
|
||||
private void addInternal(final File file, final String path, final Predicate<File> predicate) throws IOException {
|
||||
if (null != predicate && false == predicate.test(file)) {
|
||||
if (null != predicate && ! predicate.test(file)) {
|
||||
return;
|
||||
}
|
||||
final ArchiveOutputStream out = this.out;
|
||||
|
@@ -118,7 +118,7 @@ public class SevenZExtractor implements Extractor, RandomAccess {
|
||||
public InputStream getFirst(final Predicate<ArchiveEntry> predicate) {
|
||||
final SevenZFile sevenZFile = this.sevenZFile;
|
||||
for (final SevenZArchiveEntry entry : sevenZFile.getEntries()) {
|
||||
if (null != predicate && false == predicate.test(entry)) {
|
||||
if (null != predicate && ! predicate.test(entry)) {
|
||||
continue;
|
||||
}
|
||||
if (entry.isDirectory()) {
|
||||
@@ -144,12 +144,12 @@ public class SevenZExtractor implements Extractor, RandomAccess {
|
||||
* @throws IOException IO异常
|
||||
*/
|
||||
private void extractInternal(final File targetDir, final Predicate<ArchiveEntry> predicate) throws IOException {
|
||||
Assert.isTrue(null != targetDir && ((false == targetDir.exists()) || targetDir.isDirectory()), "target must be dir.");
|
||||
Assert.isTrue(null != targetDir && ((! targetDir.exists()) || targetDir.isDirectory()), "target must be dir.");
|
||||
final SevenZFile sevenZFile = this.sevenZFile;
|
||||
SevenZArchiveEntry entry;
|
||||
File outItemFile;
|
||||
while (null != (entry = sevenZFile.getNextEntry())) {
|
||||
if (null != predicate && false == predicate.test(entry)) {
|
||||
if (null != predicate && ! predicate.test(entry)) {
|
||||
continue;
|
||||
}
|
||||
outItemFile = FileUtil.file(targetDir, entry.getName());
|
||||
|
@@ -113,10 +113,10 @@ public class StreamExtractor implements Extractor {
|
||||
ArchiveEntry entry;
|
||||
try {
|
||||
while (null != (entry = in.getNextEntry())) {
|
||||
if (null != predicate && false == predicate.test(entry)) {
|
||||
if (null != predicate && ! predicate.test(entry)) {
|
||||
continue;
|
||||
}
|
||||
if (entry.isDirectory() || false == in.canReadEntryData(entry)) {
|
||||
if (entry.isDirectory() || ! in.canReadEntryData(entry)) {
|
||||
// 目录或无法读取的文件直接跳过
|
||||
continue;
|
||||
}
|
||||
@@ -155,15 +155,15 @@ public class StreamExtractor implements Extractor {
|
||||
* @throws IOException IO异常
|
||||
*/
|
||||
private void extractInternal(final File targetDir, final Predicate<ArchiveEntry> predicate) throws IOException {
|
||||
Assert.isTrue(null != targetDir && ((false == targetDir.exists()) || targetDir.isDirectory()), "target must be dir.");
|
||||
Assert.isTrue(null != targetDir && ((! targetDir.exists()) || targetDir.isDirectory()), "target must be dir.");
|
||||
final ArchiveInputStream in = this.in;
|
||||
ArchiveEntry entry;
|
||||
File outItemFile;
|
||||
while (null != (entry = in.getNextEntry())) {
|
||||
if (null != predicate && false == predicate.test(entry)) {
|
||||
if (null != predicate && ! predicate.test(entry)) {
|
||||
continue;
|
||||
}
|
||||
if (false == in.canReadEntryData(entry)) {
|
||||
if (! in.canReadEntryData(entry)) {
|
||||
// 无法读取的文件直接跳过
|
||||
continue;
|
||||
}
|
||||
|
@@ -186,13 +186,13 @@ public abstract class AbstractFtp implements Closeable {
|
||||
if (StrUtil.isNotEmpty(s)) {
|
||||
boolean exist = true;
|
||||
try {
|
||||
if (false == cd(s)) {
|
||||
if (! cd(s)) {
|
||||
exist = false;
|
||||
}
|
||||
} catch (final FtpException e) {
|
||||
exist = false;
|
||||
}
|
||||
if (false == exist) {
|
||||
if (! exist) {
|
||||
//目录不存在时创建
|
||||
mkdir(s);
|
||||
cd(s);
|
||||
|
@@ -232,7 +232,7 @@ public class Ftp extends AbstractFtp {
|
||||
throw new IORuntimeException(e);
|
||||
}
|
||||
final int replyCode = client.getReplyCode(); // 是否成功登录服务器
|
||||
if (false == FTPReply.isPositiveCompletion(replyCode)) {
|
||||
if (! FTPReply.isPositiveCompletion(replyCode)) {
|
||||
try {
|
||||
client.disconnect();
|
||||
} catch (final IOException e) {
|
||||
@@ -369,7 +369,7 @@ public class Ftp extends AbstractFtp {
|
||||
String fileName;
|
||||
for (final FTPFile ftpFile : ftpFiles) {
|
||||
fileName = ftpFile.getName();
|
||||
if (false == StrUtil.equals(".", fileName) && false == StrUtil.equals("..", fileName)) {
|
||||
if (! StrUtil.equals(".", fileName) && ! StrUtil.equals("..", fileName)) {
|
||||
if (null == predicate || predicate.test(ftpFile)) {
|
||||
result.add(ftpFile);
|
||||
}
|
||||
@@ -390,7 +390,7 @@ public class Ftp extends AbstractFtp {
|
||||
String pwd = null;
|
||||
if (StrUtil.isNotBlank(path)) {
|
||||
pwd = pwd();
|
||||
if (false == cd(path)) {
|
||||
if (! cd(path)) {
|
||||
throw new FtpException("Change dir to [{}] error, maybe path not exist!", path);
|
||||
}
|
||||
}
|
||||
@@ -455,7 +455,7 @@ public class Ftp extends AbstractFtp {
|
||||
final String pwd = pwd();
|
||||
final String fileName = FileNameUtil.getName(path);
|
||||
final String dir = StrUtil.removeSuffix(path, fileName);
|
||||
if (false == cd(dir)) {
|
||||
if (! cd(dir)) {
|
||||
throw new FtpException("Change dir to [{}] error, maybe dir not exist!", path);
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ public class Ftp extends AbstractFtp {
|
||||
childPath = StrUtil.format("{}/{}", dirPath, name);
|
||||
if (ftpFile.isDirectory()) {
|
||||
// 上级和本级目录除外
|
||||
if (false == ".".equals(name) && false == "..".equals(name)) {
|
||||
if (! ".".equals(name) && ! "..".equals(name)) {
|
||||
delDir(childPath);
|
||||
}
|
||||
} else {
|
||||
@@ -518,7 +518,7 @@ public class Ftp extends AbstractFtp {
|
||||
@Override
|
||||
public boolean uploadFile(final String remotePath, final File file) {
|
||||
Assert.notNull(file, "file to upload is null !");
|
||||
if (false == FileUtil.isFile(file)) {
|
||||
if (! FileUtil.isFile(file)) {
|
||||
throw new FtpException("[{}] is not a file!", file);
|
||||
}
|
||||
return uploadFile(remotePath, file.getName(), file);
|
||||
@@ -576,7 +576,7 @@ public class Ftp extends AbstractFtp {
|
||||
|
||||
if (StrUtil.isNotBlank(remotePath)) {
|
||||
mkDirs(remotePath);
|
||||
if (false == cd(remotePath)) {
|
||||
if (! cd(remotePath)) {
|
||||
throw new FtpException("Change dir to [{}] error, maybe dir not exist!", remotePath);
|
||||
}
|
||||
}
|
||||
@@ -601,7 +601,7 @@ public class Ftp extends AbstractFtp {
|
||||
* @param uploadFile 上传文件或目录
|
||||
*/
|
||||
public void upload(final String remotePath, final File uploadFile) {
|
||||
if (false == FileUtil.isDirectory(uploadFile)) {
|
||||
if (! FileUtil.isDirectory(uploadFile)) {
|
||||
this.uploadFile(remotePath, uploadFile);
|
||||
return;
|
||||
}
|
||||
@@ -656,9 +656,9 @@ public class Ftp extends AbstractFtp {
|
||||
srcFile = StrUtil.format("{}/{}", sourcePath, fileName);
|
||||
destFile = FileUtil.file(destDir, fileName);
|
||||
|
||||
if (false == ftpFile.isDirectory()) {
|
||||
if (! ftpFile.isDirectory()) {
|
||||
// 本地不存在文件或者ftp上文件有修改则下载
|
||||
if (false == FileUtil.exists(destFile)
|
||||
if (! FileUtil.exists(destFile)
|
||||
|| (ftpFile.getTimestamp().getTimeInMillis() > destFile.lastModified())) {
|
||||
download(srcFile, destFile);
|
||||
}
|
||||
@@ -682,7 +682,7 @@ public class Ftp extends AbstractFtp {
|
||||
if (outFile.isDirectory()) {
|
||||
outFile = new File(outFile, fileName);
|
||||
}
|
||||
if (false == outFile.exists()) {
|
||||
if (! outFile.exists()) {
|
||||
FileUtil.touch(outFile);
|
||||
}
|
||||
try (final OutputStream out = FileUtil.getOutputStream(outFile)) {
|
||||
@@ -719,7 +719,7 @@ public class Ftp extends AbstractFtp {
|
||||
pwd = pwd();
|
||||
}
|
||||
|
||||
if (false == cd(path)) {
|
||||
if (! cd(path)) {
|
||||
throw new FtpException("Change dir to [{}] error, maybe dir not exist!", path);
|
||||
}
|
||||
|
||||
|
@@ -649,7 +649,7 @@ public class MailAccount implements Serializable {
|
||||
}
|
||||
if (null == this.auth) {
|
||||
// 如果密码非空白,则使用认证模式
|
||||
this.auth = (false == StrUtil.isBlank(this.pass));
|
||||
this.auth = (! StrUtil.isBlank(this.pass));
|
||||
}
|
||||
if (null == this.port) {
|
||||
// 端口在SSL状态下默认与socketFactoryPort一致,非SSL状态下默认为25
|
||||
|
@@ -55,7 +55,7 @@ public class TinyPinyinEngine implements PinyinEngine {
|
||||
|
||||
@Override
|
||||
public String getPinyin(final char c) {
|
||||
if(false == Pinyin.isChinese(c)){
|
||||
if(! Pinyin.isChinese(c)){
|
||||
return String.valueOf(c);
|
||||
}
|
||||
return Pinyin.toPinyin(c).toLowerCase();
|
||||
|
@@ -435,7 +435,7 @@ public class JschUtil {
|
||||
public static Channel createChannel(final Session session, final ChannelType channelType) {
|
||||
final Channel channel;
|
||||
try {
|
||||
if (false == session.isConnected()) {
|
||||
if (! session.isConnected()) {
|
||||
session.connect();
|
||||
}
|
||||
channel = session.openChannel(channelType.getValue());
|
||||
|
@@ -307,7 +307,7 @@ public class Sftp extends AbstractFtp {
|
||||
* @since 4.0.5
|
||||
*/
|
||||
public List<String> lsFiles(final String path) {
|
||||
return ls(path, t -> false == t.getAttrs().isDir());
|
||||
return ls(path, t -> ! t.getAttrs().isDir());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -353,7 +353,7 @@ public class Sftp extends AbstractFtp {
|
||||
try {
|
||||
channel.ls(path, entry -> {
|
||||
final String fileName = entry.getFilename();
|
||||
if (false == StrUtil.equals(".", fileName) && false == StrUtil.equals("..", fileName)) {
|
||||
if (! StrUtil.equals(".", fileName) && ! StrUtil.equals("..", fileName)) {
|
||||
if (null == predicate || predicate.test(entry)) {
|
||||
entryList.add(entry);
|
||||
}
|
||||
@@ -361,7 +361,7 @@ public class Sftp extends AbstractFtp {
|
||||
return LsEntrySelector.CONTINUE;
|
||||
});
|
||||
} catch (final SftpException e) {
|
||||
if (false == StrUtil.startWithIgnoreCase(e.getMessage(), "No such file")) {
|
||||
if (! StrUtil.startWithIgnoreCase(e.getMessage(), "No such file")) {
|
||||
throw new JschRuntimeException(e);
|
||||
}
|
||||
// 文件不存在忽略
|
||||
@@ -446,7 +446,7 @@ public class Sftp extends AbstractFtp {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean delDir(final String dirPath) {
|
||||
if (false == cd(dirPath)) {
|
||||
if (! cd(dirPath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -460,7 +460,7 @@ public class Sftp extends AbstractFtp {
|
||||
String fileName;
|
||||
for (final LsEntry entry : list) {
|
||||
fileName = entry.getFilename();
|
||||
if (false == ".".equals(fileName) && false == "..".equals(fileName)) {
|
||||
if (! ".".equals(fileName) && ! "..".equals(fileName)) {
|
||||
if (entry.getAttrs().isDir()) {
|
||||
delDir(fileName);
|
||||
} else {
|
||||
@@ -469,7 +469,7 @@ public class Sftp extends AbstractFtp {
|
||||
}
|
||||
}
|
||||
|
||||
if (false == cd("..")) {
|
||||
if (! cd("..")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -490,7 +490,7 @@ public class Sftp extends AbstractFtp {
|
||||
* @since 5.7.6
|
||||
*/
|
||||
public void upload(final String remotePath, final File file) {
|
||||
if (false == FileUtil.exists(file)) {
|
||||
if (! FileUtil.exists(file)) {
|
||||
return;
|
||||
}
|
||||
if (file.isDirectory()) {
|
||||
@@ -514,7 +514,7 @@ public class Sftp extends AbstractFtp {
|
||||
@SuppressWarnings("resource")
|
||||
@Override
|
||||
public boolean uploadFile(final String destPath, final File file) {
|
||||
if(false == FileUtil.isFile(file)){
|
||||
if(! FileUtil.isFile(file)){
|
||||
throw new FtpException("[{}] is not a file!", file);
|
||||
}
|
||||
this.mkDirs(destPath);
|
||||
@@ -634,9 +634,9 @@ public class Sftp extends AbstractFtp {
|
||||
srcFile = StrUtil.format("{}/{}", sourcePath, fileName);
|
||||
destFile = FileUtil.file(destDir, fileName);
|
||||
|
||||
if (false == item.getAttrs().isDir()) {
|
||||
if (! item.getAttrs().isDir()) {
|
||||
// 本地不存在文件或者ftp上文件有修改则下载
|
||||
if (false == FileUtil.exists(destFile)
|
||||
if (! FileUtil.exists(destFile)
|
||||
|| (item.getAttrs().getMTime() > (destFile.lastModified() / 1000))) {
|
||||
download(srcFile, destFile);
|
||||
}
|
||||
|
Reference in New Issue
Block a user