FSUResolverTest.java
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import com.tianbo.util.IO.FileTool;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class FSUResolverTest {
public static void main(String[] args) {
File file = new File("/Users/mrz/Documents/java项目/新郑机场/util/fsu.txt");
List<String> list = new ArrayList<>();
try {
String Str = FileTool.readfile(file);
// 报文发送地址
String pattern_send = "QD\\s(.*)";
// 报文接收地址
String pattern_recive = ".([A-Z0-9]{7})\\s\\d{6}";
//报文类型及版本
String pattern_type = "(FSU|FFM|FWB|FHL|UCM|SCM)/(\\d+)";
//运单信息
String pattern_awb = "(\\d{3}-\\d{8})" +
"(CGO)(AMS)" +
"/([TPSDM])(\\d+)" +
"([K])" +
"([1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*|\\d+)";
//FSU_业务类型
String pattern_fsu_type = "(RCS|FOH|DEP|RCF|NFD)/(.*)";
// 创建 Pattern 对象
Pattern pattern = Pattern.compile(pattern_fsu_type,Pattern.MULTILINE);
// 现在创建 matcher 对象
Matcher matcher = pattern.matcher(Str);
while (matcher.find()) {
list.add(matcher.group());
System.out.println("适配结果: " + matcher.group(1) );
}
System.out.println(list);
}catch (Exception e){
e.printStackTrace();
}
}
}