1 | //NAME:Caleb Bird
|
---|
2 | //ID: 1289680
|
---|
3 | //??References??
|
---|
4 | //https://stackoverflow.com/questions/13796451/how-to-extract-a-string-between-two-delimiters
|
---|
5 |
|
---|
6 | import java.io.BufferedReader;
|
---|
7 | import java.io.FileReader;
|
---|
8 | import java.io.FileWriter;
|
---|
9 |
|
---|
10 | public class TabProcMetaListGen {
|
---|
11 | public static void main(String[] args) {
|
---|
12 | try{
|
---|
13 |
|
---|
14 |
|
---|
15 | if (args.length != 1) {
|
---|
16 | System.out.println("Usage: TabProcMetaListGen <inputFilename> <outputFilename>");
|
---|
17 | }
|
---|
18 | else {
|
---|
19 | String inputFilename = args[0];
|
---|
20 | //String outputFilename = args[1];
|
---|
21 |
|
---|
22 | System.out.println("Processing: " + inputFilename);
|
---|
23 |
|
---|
24 | FileReader fileReader = new FileReader(inputFilename);
|
---|
25 | BufferedReader buf = new BufferedReader(fileReader);
|
---|
26 | //FileWriter fw = new FileWriter(outputFilename);
|
---|
27 | String line = null;
|
---|
28 | String[] item;
|
---|
29 |
|
---|
30 | //Splits into each record
|
---|
31 | while ((line = buf.readLine()) != null) {
|
---|
32 |
|
---|
33 | //Splits by tab, leaves "" for every blank entry
|
---|
34 | //Check items to be equal
|
---|
35 | //System.out.println(line);
|
---|
36 | if(line.contains("<htd:numpages>")){
|
---|
37 | String result = line.substring(line.indexOf(">")+1, line.indexOf(">")+2);
|
---|
38 | System.out.println(result);
|
---|
39 | }
|
---|
40 | if(line.contains("<id>")){
|
---|
41 | String result = line.substring(line.indexOf(">")+1, line.indexOf("</"));
|
---|
42 | System.out.println(result);
|
---|
43 | }
|
---|
44 |
|
---|
45 | }
|
---|
46 | buf.close();
|
---|
47 | //fw.close();
|
---|
48 | }
|
---|
49 | }catch(Exception e){
|
---|
50 | e.printStackTrace();
|
---|
51 | }
|
---|
52 | }
|
---|
53 | }
|
---|
54 |
|
---|
55 | //REFERNECES
|
---|
56 | //https://www.javatpoint.com/java-filewriter-class
|
---|
57 | //https://docs.oracle.com/javase/8/docs/api/index.html?java/io/FileWriter.html
|
---|