File: RedirectTest.java

package info (click to toggle)
bbmap 39.20%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,024 kB
  • sloc: java: 312,743; sh: 18,099; python: 5,247; ansic: 2,074; perl: 96; makefile: 39; xml: 38
file content (78 lines) | stat: -rwxr-xr-x 1,699 bytes parent folder | download | duplicates (4)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package jgi;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import dna.Data;
import fileIO.PipeThread;
import fileIO.ReadWrite;
import shared.Shared;

/**
 * @author Brian Bushnell
 * @date Jan 22, 2013
 *
 */
public class RedirectTest {
	
	public static void main(String[] args) throws IOException{
		
		String fin=args[0];
//		String fout=args[1];
		
		System.out.println("fin="+fin);
		
		InputStream in=null;
		final OutputStream os=System.out;
		InputStream es=null;
		Process p=null;

		System.out.println("Samtools="+Data.SAMTOOLS());
		System.out.println("Gzip="+Data.GZIP());
		System.out.println("Pigz="+Data.PIGZ());
		System.out.println("Gunzip="+Data.GUNZIP());
		
		if(Shared.WINDOWS){
			System.out.println("WINDOWS");
			in=ReadWrite.getInputStream(fin, false, false);
		}else{
			System.out.println("LINUX");
			p=Runtime.getRuntime().exec("gunzip -c -d "+fin);
			in=p.getInputStream();
			es=p.getErrorStream();
			assert(es!=null);
			PipeThread et=new PipeThread(es, System.err);
			et.start();
			System.out.println(p);
		}
		
		final byte[] buf=new byte[4096];
		for(int len=in.read(buf); len>0; len=in.read(buf)){
			os.write(buf, 0, len);
		}
		
		in.close();
		if(es!=null){es.close();}
		ReadWrite.close(os);
		
	}
	
	public static void main_0(String[] args) throws IOException{
		
		String fin=args[0];
		String fout=args[1];
		
		InputStream in=ReadWrite.getInputStream(fin, false, false);
		
		OutputStream os=System.out;
		
		byte[] buf=new byte[4096];
		
		for(int len=in.read(buf); len>0; len=in.read(buf)){
			os.write(buf, 0, len);
		}
		
	}
	
}