Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a7efd76c6 |
@@ -85,13 +85,13 @@ The framework is not the framework for beautifying UI, but to simplify the step
|
||||
- [ ] Data valication
|
||||
- [ ] Optimize performance
|
||||
|
||||
## ~~Maven Repository~~
|
||||
## Maven Repository
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.gitee.Biubiuyuyu</groupId>
|
||||
<artifactId>javafx-plus</artifactId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
35
pom.xml
35
pom.xml
@@ -25,6 +25,7 @@
|
||||
<slf4j-log4j12.version>1.7.21</slf4j-log4j12.version>
|
||||
<tomcat.version>9.0.48</tomcat.version>
|
||||
<commons-lang3.version>3.12.0</commons-lang3.version>
|
||||
<commons-io.version>2.11.0</commons-io.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- 第三方动态代理库 -->
|
||||
@@ -60,6 +61,12 @@
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons-io.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<distributionManagement>
|
||||
@@ -118,6 +125,20 @@
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Source 开源 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@@ -126,20 +147,6 @@
|
||||
<id>release</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Source -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- Javadoc -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
||||
@@ -3,6 +3,7 @@ package cn.edu.scau.biubiusuisui.utils;
|
||||
import cn.edu.scau.biubiusuisui.exception.ProtocolNotSupport;
|
||||
import cn.edu.scau.biubiusuisui.log.FXPlusLoggerFactory;
|
||||
import cn.edu.scau.biubiusuisui.log.IFXPlusLogger;
|
||||
import org.apache.tomcat.util.http.fileupload.IOUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
@@ -34,12 +35,28 @@ public class FileUtil {
|
||||
* @param filePath
|
||||
* @return
|
||||
* @description 读取resources文件夹下的file,相对于resources的文件路径,如 resources/config.conf 则只需 config.conf
|
||||
* @since 1.2.0 update: 使用getResourcesAsStream读取,屏蔽jar包读取障碍
|
||||
*/
|
||||
public static String readFileFromResources(String filePath) throws UnsupportedEncodingException {
|
||||
URL url = FileUtil.class.getClassLoader().getResource(filePath);
|
||||
if (url != null) {
|
||||
String path = StringUtil.getRootPath(url);
|
||||
return readFile(path);
|
||||
InputStream is = FileUtil.class.getClassLoader().getResourceAsStream(filePath);
|
||||
if (is == null) {
|
||||
return "";
|
||||
}
|
||||
StringBuffer content = new StringBuffer();
|
||||
try (
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(is);
|
||||
BufferedReader br = new BufferedReader(inputStreamReader);
|
||||
) {
|
||||
String temp;
|
||||
while ((temp = br.readLine()) != null) {
|
||||
// 一次读入一行数据
|
||||
content.append(temp + "\r\n");
|
||||
}
|
||||
return content.toString();
|
||||
} catch (IOException e) {
|
||||
logger.error("reading file error", e);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -60,8 +77,7 @@ public class FileUtil {
|
||||
content.append(temp + "\r\n");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
logger.error("reading file error", e);
|
||||
}
|
||||
return content.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user