Skip to content

Commit dabaece

Browse files
committed
Merge remote-tracking branch 'origin/master'
# Conflicts: # pom.xml
2 parents 5c27e60 + 9cac607 commit dabaece

10 files changed

Lines changed: 446 additions & 43 deletions

File tree

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,12 @@
2020
<artifactId>mysql-connector-java</artifactId>
2121
<version>6.0.6</version>
2222
</dependency>
23+
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
24+
<dependency>
25+
<groupId>org.projectlombok</groupId>
26+
<artifactId>lombok</artifactId>
27+
<version>1.18.6</version>
28+
<scope>provided</scope>
29+
</dependency>
2330
</dependencies>
2431
</project>

src/main/java/basic/collection/testSet/CharTreeSet.java renamed to src/main/java/basic/collection/set/CharTreeSet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package basic.collection.testSet;
1+
package basic.collection.set;
22

33
import java.util.SortedSet;
44
import java.util.TreeSet;

src/main/java/basic/collection/testSet/ListsTest.java renamed to src/main/java/basic/collection/set/ListsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package basic.collection.testSet;
1+
package basic.collection.set;
22

33
import java.util.Iterator;
44
import java.util.LinkedList;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package basic.collection.set;
2+
3+
import java.util.Collections;
4+
import java.util.Iterator;
5+
import java.util.SortedSet;
6+
import java.util.TreeSet;
7+
8+
/**
9+
* ����TreeSet��TreeSet�ڲ�����Comparable������ģ�TreeSet������ģ�LinkedHashSet�ڲ�Ҳ�������
10+
*
11+
* @author Administrator
12+
*/
13+
public class SortedSetTest {
14+
15+
public static void main(String[] args) {
16+
SortedSet<String> sortedSet = new TreeSet<>();
17+
Collections.addAll(sortedSet, "one two three four five six seven eigh".split(" "));
18+
System.out.println(sortedSet);
19+
String low = sortedSet.first();
20+
String high = sortedSet.last();
21+
System.out.println(low);
22+
System.out.println(high);
23+
Iterator<String> it = sortedSet.iterator();
24+
for (int i = 0; i <= 6; i++) {
25+
if (i == 3) {
26+
low = it.next();
27+
}
28+
if (i == 6) {
29+
high = it.next();
30+
} else {
31+
it.next();
32+
}
33+
}
34+
System.out.println(low);
35+
System.out.println(high);
36+
System.out.println(sortedSet.subSet(low, high));
37+
System.out.println(sortedSet.headSet(high));
38+
System.out.println(sortedSet.tailSet(low));
39+
}
40+
}

src/main/java/basic/collection/testSet/TypesForSets.java renamed to src/main/java/basic/collection/set/TypesForSets.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package basic.collection.testSet;
1+
package basic.collection.set;
22

33
import java.util.HashSet;
44
import java.util.LinkedHashSet;

src/main/java/basic/collection/testSet/treeset/TreeSetTest.java renamed to src/main/java/basic/collection/set/treeset/TreeSetTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package basic.collection.testSet.treeset;
1+
package basic.collection.set.treeset;
22

33
import java.util.TreeSet;
44

src/main/java/basic/collection/testSet/SortedSetTest.java

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/main/java/zm/FileOperate.java

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
package zm;
2+
3+
import java.io.BufferedReader;
4+
import java.io.BufferedWriter;
5+
import java.io.File;
6+
import java.io.FileInputStream;
7+
import java.io.FileWriter;
8+
import java.io.IOException;
9+
import java.io.InputStreamReader;
10+
11+
/**
12+
* <p>title:</p>
13+
* <p>description:</p>
14+
*
15+
* @author yangqc
16+
* @date Created in 2018-03-29
17+
* @modified By yangqc
18+
*/
19+
public class FileOperate {
20+
21+
private static final String SPLIT = "@";
22+
23+
private static void operateFile(String filePath) throws IOException {
24+
// 相对路径,如果没有则要建立一个新的output。txt文件
25+
File file = new File(filePath);
26+
// 建立一个输入流对象reader
27+
InputStreamReader reader = new InputStreamReader(
28+
new FileInputStream(file));
29+
BufferedReader br = new BufferedReader(reader);
30+
System.out.println(file.getName() + "**");
31+
File writename = new File("C:\\Users\\yangqc\\Desktop\\" + file.getName());
32+
// 创建新文件
33+
writename.createNewFile();
34+
BufferedWriter out = new BufferedWriter(new FileWriter(writename));
35+
String line = "";
36+
String[] arrays = null;
37+
while ((line = br.readLine()) != null) {
38+
System.out.println(line);
39+
if (!line.contains("【")) {
40+
if (arrays != null) {
41+
for (String s : arrays) {
42+
if (s != null && !"".equals(s)) {
43+
out.write(s + SPLIT);
44+
} else {
45+
out.write("不详" + SPLIT);
46+
}
47+
}
48+
//换行
49+
out.write("\r\n");
50+
out.flush();
51+
}
52+
arrays = new String[7];
53+
continue;
54+
}
55+
if (line.contains("标题")) {
56+
arrays[0] = operateTitle(line);
57+
} else if (line.contains("作者单位")) {
58+
arrays[2] = operateAuthorCompany(line);
59+
} else if (line.contains("作者")) {
60+
arrays[1] = operateAuthor(line);
61+
} else if (line.contains("出处")) {
62+
arrays[3] = operateSource(line)[0];
63+
arrays[4] = operateSource(line)[1];
64+
} else if (line.contains("国省市名")) {
65+
arrays[5] = operateProvince(line);
66+
arrays[6] = getArea(arrays[5]);
67+
}
68+
}
69+
for (String s : arrays) {
70+
if (s != null && !s.equals("")) {
71+
out.write(s + SPLIT);
72+
} else {
73+
out.write("不详" + SPLIT);
74+
}
75+
}
76+
//换行
77+
out.write("\r\n");
78+
out.flush();
79+
// 最后记得关闭文件
80+
out.close();
81+
}
82+
83+
/**
84+
* 处理标题
85+
*/
86+
private static String operateTitle(String content) {
87+
StringBuilder names = new StringBuilder();
88+
String[] contents = content.split(":");
89+
for (int i = 1; i < contents.length; i++) {
90+
names.append(contents[i]).append(":");
91+
}
92+
names = new StringBuilder(names.substring(0, names.length() - 1));
93+
return names.toString();
94+
}
95+
96+
private static String operateAuthorCompany(String content) {
97+
String names = "";
98+
if (content != null && content.length() > 0) {
99+
names = content.split(":")[1];
100+
}
101+
return names;
102+
}
103+
104+
/**
105+
* 处理作者
106+
*/
107+
private static String operateAuthor(String content) {
108+
return content.split(":")[1];
109+
}
110+
111+
/**
112+
* 处理省市
113+
*/
114+
private static String operateProvince(String content) {
115+
String[] s = content.split(":");
116+
if (s.length <= 1) {
117+
return "不详";
118+
}
119+
return s[1];
120+
}
121+
122+
/**
123+
* 处理出处 数组第一个元素是期刊名称,数组第二个元素是年份 一共两个元素
124+
*/
125+
private static String[] operateSource(String content) {
126+
String[] arrays = content.split(":");
127+
if (arrays.length <= 1) {
128+
return new String[]{"不详", "不详"};
129+
}
130+
String s1 = arrays[1];
131+
String year = "";
132+
if ((year = s1.split(";")[1]) != null && year.length() > 0) {
133+
if (year.split("\\.").length > 0) {
134+
year = year.split("\\.")[0];
135+
}
136+
}
137+
String[] s2 = new String[]{s1.split(";")[0], year};
138+
return s2;
139+
}
140+
141+
private static String getArea(String province) {
142+
if (province == null) {
143+
return "不详";
144+
} else if ("上海".equals(province) || "江苏".equals(province) || "浙江".equals(province) ||
145+
"安徽".equals(province) || "福建".equals(province) || "江西".equals(province) ||
146+
"山东".equals(province) || "台湾".equals(province)
147+
) {
148+
return "华东";
149+
} else if ("北京".equals(province) || "天津".equals(province) || "山西".equals(province)
150+
|| "河北".equals(province) || "内蒙古".equals(province)) {
151+
return "华北";
152+
} else if ("四川".equals(province) || "贵州".equals(province) || "云南".equals(province) || "重庆"
153+
.equals(province) || "西藏".equals(province)) {
154+
return "西南";
155+
} else if ("陕西".equals(province) || "甘肃".equals(province) || "青海".equals(province) || "宁夏"
156+
.equals(province) || "新疆".equals(province)) {
157+
return "西北";
158+
} else if ("黑龙江".equals(province) || "吉林".equals(province) || "辽宁".equals(province)) {
159+
return "东北";
160+
} else if ("河南".equals(province) || "湖北".equals(province) || "湖南".equals(province)) {
161+
return "华中";
162+
} else if ("广东".equals(province) || "广西".equals(province) || "海南".equals(province) || "香港"
163+
.equals(province) || "澳门".equals(province)) {
164+
return "华南";
165+
} else if ("不详".equals(province)) {
166+
return "不详";
167+
} else {
168+
return "";
169+
}
170+
}
171+
172+
public static void main(String[] args) throws IOException {
173+
operateFile("C:\\Users\\yangqc\\Desktop\\zm-5.3\\UC中华医学会期刊.txt");
174+
}
175+
}

0 commit comments

Comments
 (0)