Compare commits
4 Commits
f9d6b26cdf
...
c0b4f41ea4
| Author | SHA1 | Date | |
|---|---|---|---|
| c0b4f41ea4 | |||
| 96ad0e2912 | |||
| f9d7221e0f | |||
| 3effab4def |
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,6 +8,7 @@ target/
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
.idea/CopilotChatHistory.xml
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
57
pom.xml
57
pom.xml
@ -20,17 +20,60 @@
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<source>21</source>
|
||||
<target>21</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>3.1.3</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.11.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>timi_nexus</id>
|
||||
<url>https://nexus.imyeyu.com/repository/maven-releases/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>timi_nexus</id>
|
||||
<url>https://nexus.imyeyu.com/repository/maven-public/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.imyeyu.utils</groupId>
|
||||
|
||||
@ -11,6 +11,7 @@ import com.imyeyu.utils.Text;
|
||||
import javax.naming.NoPermissionException;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
@ -352,6 +353,19 @@ public class IO implements OS.FileSystem {
|
||||
}
|
||||
}
|
||||
|
||||
public static String[] toStringLines(File file) throws IOException {
|
||||
return toString(file).split("\r\n|[\r\n]");
|
||||
}
|
||||
|
||||
public static void toStringLines(File file, CallbackArg<String> lineCallback) throws IOException {
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
lineCallback.handler(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取文件为字符串(UTF-8)
|
||||
*
|
||||
@ -895,8 +909,13 @@ public class IO implements OS.FileSystem {
|
||||
* @param path jar 内文件路径,不需要 / 开始,如 config/TimiJava.ini
|
||||
* @return 数据流
|
||||
*/
|
||||
public static boolean resourceExist(Class<?> clazz, String path) {
|
||||
return resourceToInputStream(clazz, path) != null;
|
||||
public static boolean resourceExist(Class<?> clazz, String path) throws IOException {
|
||||
InputStream stream = resourceToInputStream(clazz, path);
|
||||
if (stream != null) {
|
||||
stream.close();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user