Package cn.net.pap.common.file
Class ReadTxtToStringUtil
java.lang.Object
cn.net.pap.common.file.ReadTxtToStringUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringdetectCharsetUsingICU4J(String filePath) 文件编码static StringdetectEncoding(ByteArrayOutputStream outputStream) 入参调整,假设 文件流 的来源如下所示 ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); boolean success = ftpClient.retrieveFile(TEST_FILE, outputStream);static StringdetectEncoding(File file) 检测文件编码,先检测 BOM,如果没有再使用 UniversalDetectorstatic StringreadFileContent(File file) 读取文件内容为 String(自动识别编码)readFileLines(File file) 读取文件内容为 List
-
Constructor Details
-
ReadTxtToStringUtil
public ReadTxtToStringUtil()
-
-
Method Details
-
detectEncoding
检测文件编码,先检测 BOM,如果没有再使用 UniversalDetector- Throws:
IOException
-
detectEncoding
入参调整,假设 文件流 的来源如下所示 ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); boolean success = ftpClient.retrieveFile(TEST_FILE, outputStream);- Parameters:
outputStream-- Returns:
- Throws:
IOException
-
readFileContent
读取文件内容为 String(自动识别编码)- Throws:
IOException
-
readFileLines
读取文件内容为 List- Throws:
IOException
-
detectCharsetUsingICU4J
文件编码- Parameters:
filePath-- Returns:
- Throws:
IOException
-