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 CallNamedPipe { 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], 20 SmbNamedPipe.PIPE_TYPE_RDWR | SmbNamedPipe.PIPE_TYPE_CALL ); 21 OutputStream out = pipe.getNamedPipeOutputStream(); 22 InputStream in = pipe.getNamedPipeInputStream(); 23 24 int n = fin.read( b ); 25 System.out.println( "writing " + n + " bytes" ); 26 out.write( b, 0, n ); 27 n = in.read(b); 28 System.out.println( "read " + n + " bytes" ); 29 fos.write(b, 0, n ); 30 31 fin.close(); 32 fos.close(); 33 out.close(); 34 } 35 } 36 | Popular Tags |