mirror of
https://gitee.com/kekingcn/file-online-preview.git
synced 2026-03-14 21:23:47 +08:00
fix some codestyle problem
This commit is contained in:
@@ -17,14 +17,18 @@ import javax.media.jai.RenderedOp;
|
||||
import java.awt.image.RenderedImage;
|
||||
import java.awt.image.renderable.ParameterBlock;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ConvertPicUtil {
|
||||
|
||||
private static final int FIT_WIDTH = 500;
|
||||
private static final int FIT_HEIGHT = 900;
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(ConvertPicUtil.class);
|
||||
private final static String fileDir = ConfigConstants.getFileDir();
|
||||
/**
|
||||
@@ -77,10 +81,7 @@ public class ConvertPicUtil {
|
||||
RenderedOp renderedOp = JAI.create("filestore", pb);
|
||||
renderedOp.dispose();
|
||||
logger.info("每页分别保存至: " + fileJpg.getCanonicalPath());
|
||||
} else {
|
||||
// logger.info("JPG文件已存在: " + fileJpg.getCanonicalPath());
|
||||
}
|
||||
|
||||
listImageFiles.add(strJpgUrl);
|
||||
}
|
||||
|
||||
@@ -105,14 +106,12 @@ public class ConvertPicUtil {
|
||||
* @param strJpgFile 输入的jpg的路径和文件名
|
||||
* @param strPdfFile 输出的pdf的路径和文件名
|
||||
*/
|
||||
private static final int FIT_WIDTH = 500;
|
||||
private static final int FIT_HEIGHT = 900;
|
||||
public static boolean convertJpg2Pdf(String strJpgFile, String strPdfFile) {
|
||||
Document document= null;
|
||||
Document document = null;
|
||||
RandomAccessFileOrArray rafa = null;
|
||||
try {
|
||||
document = new Document();
|
||||
PdfWriter.getInstance(document, new FileOutputStream(strPdfFile));
|
||||
PdfWriter.getInstance(document, Files.newOutputStream(Paths.get(strPdfFile)));
|
||||
document.open();
|
||||
rafa = new RandomAccessFileOrArray(new FileChannelRandomAccessSource(new RandomAccessFile(strJpgFile, "r").getChannel()));
|
||||
int pages = TiffImage.getNumberOfPages(rafa);
|
||||
@@ -131,15 +130,16 @@ public class ConvertPicUtil {
|
||||
document.close();
|
||||
rafa.close();
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("错误:"+ e.getMessage());
|
||||
}
|
||||
finally {
|
||||
document.close();
|
||||
} catch (Exception e) {
|
||||
logger.error("图片转PDF异常,图片文件路径:" + strJpgFile, e);
|
||||
} finally {
|
||||
try {
|
||||
rafa.close();
|
||||
if (document != null && document.isOpen()) {
|
||||
document.close();
|
||||
}
|
||||
if (rafa != null) {
|
||||
rafa.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.UUID;
|
||||
|
||||
import static cn.keking.utils.KkFileUtils.isFtpUrl;
|
||||
|
||||
@@ -43,7 +43,6 @@ public class EncodingDetects {
|
||||
}
|
||||
|
||||
public static void readFile(String file, String code) {
|
||||
|
||||
BufferedReader fr;
|
||||
try {
|
||||
String myCode = code!=null&&!"".equals(code) ? code : "UTF8";
|
||||
|
||||
@@ -186,7 +186,7 @@ public class KkFileUtils {
|
||||
*/
|
||||
public static boolean isAllowedUpload(String file) {
|
||||
String fileType = suffixFromFileName(file);
|
||||
for (String type : ConfigConstants.getprohibit()) {
|
||||
for (String type : ConfigConstants.getProhibit()) {
|
||||
if (type.equals(fileType))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package cn.keking.utils;
|
||||
|
||||
import io.mola.galimatias.GalimatiasParseException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.Base64Utils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.util.HtmlUtils;
|
||||
@@ -24,6 +26,8 @@ import java.util.regex.Pattern;
|
||||
**/
|
||||
public class WebUtils {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(WebUtils.class);
|
||||
|
||||
/**
|
||||
* 获取标准的URL
|
||||
*
|
||||
@@ -209,7 +213,7 @@ public class WebUtils {
|
||||
* 判断地址是否正确
|
||||
* 高 2022/12/17
|
||||
*/
|
||||
public static boolean hefaurl (String url) {
|
||||
public static boolean isValidUrl(String url) {
|
||||
String regStr = "^((https|http|ftp|rtsp|mms|file)://)";//[.?*]表示匹配的就是本身
|
||||
Pattern pattern = Pattern.compile(regStr);
|
||||
Matcher matcher = pattern.matcher(url);
|
||||
@@ -253,8 +257,7 @@ public class WebUtils {
|
||||
try {
|
||||
return new String(Base64Utils.decodeFromString(source.replaceAll(" ", "+").replaceAll("\n", "")), charsets);
|
||||
} catch (Exception e) {
|
||||
System.out.println("接入方法错误,或者未使用BASE64");
|
||||
// e.printStackTrace();
|
||||
LOGGER.error("url解码异常,可能是接入方法错误或者未使用BASE64", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user