-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.java
More file actions
42 lines (37 loc) · 1.13 KB
/
script.java
File metadata and controls
42 lines (37 loc) · 1.13 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
import java.io.File;
import java.io.FileNotFoundException;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
public class script {
public static void main(String[] args) throws FileNotFoundException {
Set<String>set=new TreeSet<>();
File root=new File("../../Annotation");
for(File file:root.listFiles())
{
Scanner scanner=new Scanner(file);
while (scanner.hasNext())
{
String s=scanner.nextLine();
if(s.contains("<name>")==true)
{
int a=s.indexOf(">");
int b=s.lastIndexOf("<");
String c=s.substring(a+1,b);
set.add(c);
}
}
}
int i=1;
for (String t:set) //pbtxt
{
System.out.println("item {");
System.out.println(" id: "+i);
System.out.println(" name: '"+t+"'");
System.out.println("}\n");
i++;
}
System.out.println(set.size());
}
}