1 import jcifs.smb.SmbNamedPipe; 2 import java.io.InputStream ; 3 import java.io.OutputStream ; 4 import java.io.FileInputStream ; 5 import java.io.FileOutputStream ; 6 7 public class WaitNamedPipe { 8 9 public static void main( String [] argv ) throws Exception { 10 11 if( argv.length < 2 ) { 12 throw new IllegalArgumentException ( "args: <smburl> <filedatatosend> <filetowriterecvdata>" ); 13 } 14 15 byte[] b = new byte[65535]; 16 FileInputStream fin = new FileInputStream ( argv[1] ); 17 FileOutputStream fos = new FileOutputStream ( argv[2] ); 18 19 SmbNamedPipe pipe = new SmbNamedPipe( argv[0], SmbNamedPipe.PIPE_TYPE_RDWR ); 20 OutputStream out = pipe.getNamedPipeOutputStream(); 21 InputStream in = pipe.getNamedPipeInputStream(); 22 23 int n = fin.read( b ); 24 System.out.println( "writing " + n + " bytes" ); 25 out.write( b, 0, n ); 26 n = in.read(b); 27 System.out.println( "read " + n + " bytes" ); 28 fos.write(b, 0, n ); 29 30 fin.close(); 31 fos.close(); 32 out.close(); 33 } 34 } 35 | Popular Tags |