Debian Codegraph @

current/driver/Concatenator.java

raw symbols SCIP
1 package driver;
2
3 import fileIO.TextFile;
4 import fileIO.TextStreamWriter;
5
6 public class Concatenator {
7
8
9 public static void main(String args[]){
10
11 assert(args.length==2 && !args[1].contains(","));
12 TextStreamWriter tsw=new TextStreamWriter(args[1], false, false, true);
13 tsw.start();
14 for(String s : args[0].split(",")){
15 writeFile(s, tsw);
16 }
17 tsw.poison();
18 }
19
20 public static void writeFile(String fname, TextStreamWriter tsw){
21 TextFile tf=new TextFile(fname, false);
22 if(tsw==null){
23 for(String s=tf.nextLine(); s!=null; s=tf.nextLine()){
24 System.out.println(s);
25 }
26 }else{
27 for(String s=tf.nextLine(); s!=null; s=tf.nextLine()){
28 tsw.println(s);
29 }
30 }
31 tf.close();
32 }
33
34
35 public static StringBuilder merge(String[] fnames){
36 StringBuilder sb=new StringBuilder();
37
38 for(int i=0; i<fnames.length; i++){
39 String fname=fnames[i];
40 if(fname!=null){
41 TextFile tf=new TextFile(fname, false);
42 String[] lines=tf.toStringLines();
43 tf.close();
44 for(int j=0; j<lines.length; j++){
45 String s=lines[j];
46 lines[j]=null;
47 // if(i<2 || !s.startsWith("#")){
48 // sb.append(s);
49 // sb.append('\n');
50 // }
51 sb.append(s);
52 sb.append('\n');
53 }
54 }
55 }
56 return sb;
57 }
58
59
60 }