Skip to content

Commit ce5e55c

Browse files
committed
1.64
1 parent ccfb384 commit ce5e55c

File tree

5 files changed

+27
-14
lines changed

5 files changed

+27
-14
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package dev.felnull.fnjl;
22

33
public class FNJLBuildIn {
4-
protected static final String VERSION = "1.63";
4+
protected static final String VERSION = "1.64";
55
}

common/src/main/java/dev/felnull/fnjl/util/FNStringUtil.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.nio.charset.StandardCharsets;
77
import java.util.Base64;
88
import java.util.UUID;
9+
import java.util.regex.Pattern;
910

1011
/**
1112
* 文字列関係
@@ -15,6 +16,7 @@
1516
*/
1617
public class FNStringUtil {
1718
private static final String[] unit = {"K", "M", "G", "T", "P", "E", "Z", "Y"};
19+
private static final Pattern FILE_UNUSABLE_REGEX = Pattern.compile("[\\\\/:*?\"<>|]");
1820

1921
/**
2022
* nullが渡されたら空を返す
@@ -305,4 +307,26 @@ public static String getTimeFormat(long time, boolean hour) {
305307
return String.format("%02d:%02d:%02d", hourTime, minTime, secTime);
306308
return String.format("%02d:%02d", minTime, secTime);
307309
}
310+
311+
/**
312+
* ファイルで利用不可な文字を置き換える
313+
*
314+
* @param name ファイル名
315+
* @param escapeStr 置き換え文字
316+
* @return 置き換え済み文字
317+
*/
318+
public static String escapeFileName(String name, String escapeStr) {
319+
name = FILE_UNUSABLE_REGEX.matcher(name).replaceAll(escapeStr);
320+
return name;
321+
}
322+
323+
/**
324+
* ファイルで利用不可な文字を消し去る
325+
*
326+
* @param name ファイル名
327+
* @return 置き換え済み文字
328+
*/
329+
public static String escapeFileName(String name) {
330+
return escapeFileName(name, "");
331+
}
308332
}
Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
package dev.felnull.fnjltest;
22

3-
import dev.felnull.fnjl.util.FNDataUtil;
4-
5-
import java.io.BufferedInputStream;
6-
import java.io.BufferedOutputStream;
7-
import java.io.FileOutputStream;
8-
import java.nio.file.Files;
9-
import java.nio.file.Paths;
10-
113
public class Main {
124
public static void main(String[] args) throws Exception {
13-
int ret = FNDataUtil.inputToOutputBuff(new BufferedInputStream(Files.newInputStream(Paths.get("./test/test2.mp4"))), new BufferedOutputStream(new FileOutputStream("./test/test.mp4")), 1024);
14-
System.out.println(ret);
155
}
16-
176
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
fnjl_group=dev.felnull
22
fnjl_name=felnull-java-library
3-
fnjl_version=1.63
3+
fnjl_version=1.64
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dev.felnull.fnjln;
22

33
public class FNJLNBuildIn {
4-
protected static final String VERSION = "1.63";
4+
protected static final String VERSION = "1.64";
55

66
protected static final int NATIVE_LIBRARY_VERSION = 1;
77
}

0 commit comments

Comments
 (0)