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
   |  
Thread t = new Thread(){
			public void run(){
				String cmd = "scp /home/gldavid/seq.txt gldavid@cluster:~";
				try{
					final Process p = Runtime.getRuntime().exec(cmd);
					Thread t2 = new Thread(){
						public void run(){
							try {
								java.io.InputStream processOutput = p.getInputStream();
					            byte[] b = new byte[512];
					            int read;
					            while ( (read = processOutput.read(b) ) > 0 ) {
					            	System.out.write(b, 0, read);
					            }
					            processOutput.close();
							}
							catch(IOException ioe){
								ioe.printStackTrace();
							}
						}
					};
					try{
						synchronized(this) {
				            this.wait();
				        }
					}
					catch(InterruptedException ie){
						ie.printStackTrace();
					}
					t2.start();
				}
				catch(IOException ioe){
					ioe.printStackTrace();
				} | 
Partager