Compare commits

...

4 Commits

Author SHA1 Message Date
c0b4f41ea4 support deploy nexus 2025-10-13 10:51:11 +08:00
96ad0e2912 ignored CopilotChatHistory.xml 2025-10-13 10:51:03 +08:00
f9d7221e0f close stream for IO.resourceExist 2025-07-23 11:13:23 +08:00
3effab4def add IO.toStringLines 2025-07-23 11:11:18 +08:00
3 changed files with 72 additions and 9 deletions

1
.gitignore vendored
View File

@ -8,6 +8,7 @@ target/
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
.idea/CopilotChatHistory.xml
*.iws
*.iml
*.ipr

57
pom.xml
View File

@ -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>

View File

@ -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;
}
/**