Package java.nio.channels

Examples of java.nio.channels.Pipe.sink()


  public void testUnzipZipInputStreamFile() throws IOException {
    // Test on an unseekable input steam
    File targetFolder = _temporaryFolder.newFolder("unpacked4");

    final Pipe zipPipe = Pipe.open();
    final SinkChannel sink = zipPipe.sink();
    final SourceChannel source = zipPipe.source();
    final InputStream sourceIn = Channels.newInputStream(source);
    final OutputStream sourceOut = Channels.newOutputStream(sink);
    final ZipInputStream zis = new ZipInputStream(sourceIn);
    final FileInputStream fis = new FileInputStream(TestResources.SHARD1);
View Full Code Here


        super();
        this.logger = logger;
        try
        {
            Pipe p = Pipe.open();
            SinkChannel sink = p.sink();
            SourceChannel source = p.source();
            writer = Channels.newWriter( sink, Charset.defaultCharset().name() );
            reader = Channels.newReader( source, Charset.defaultCharset().name() );
            parser.setInput( reader );
View Full Code Here

    public PipeImpl() throws IOException {
        if (useNative) {
            Pipe pipe = Pipe.open();
            source = pipe.source();
            sink = pipe.sink();

        } else {
            PipedInputStream pipedIn = new PipedInputStream();
            try {
                pipedOut = new PipedOutputStream(pipedIn);
View Full Code Here

    public PipeImpl() throws IOException {
        if (useNative) {
            Pipe pipe = Pipe.open();
            source = pipe.source();
            sink = pipe.sink();

        } else {
            PipedInputStream pipedIn = new PipedInputStream();
            try {
                pipedOut = new PipedOutputStream(pipedIn);
View Full Code Here

  @Test
  public void testNewPipePartialReadSemantics() throws IOException {
    Pipe pipe = Pipe.open();
    int sz = 10;
    ByteBuffer buf = ByteBuffer.allocate(sz);
    pipe.sink().write(ByteBuffer.wrap("small".getBytes()));
    int rdSz = pipe.source().read(buf); // this operation blocks!
    assertTrue(rdSz <= sz);
  }

  /**
 
View Full Code Here

                try {
                    // make sure to call key.cancel() while the main thread is selecting
                    Thread.sleep(500);
                    key.cancel();
                    assertFalse(key.isValid());
                    pipe.sink().write(ByteBuffer.allocate(4)); // unblock select()
                } catch (Throwable e) {
                    failure.set(e);
                } finally {
                    complete.set(true);
                }
View Full Code Here

  /**
   * @tests java.nio.channels.Pipe#sink()
   */
  public void test_sink() throws IOException {
    Pipe pipe = Pipe.open();
    SinkChannel sink = pipe.sink();
    assertTrue(sink.isBlocking());
  }

  /**
   * @tests java.nio.channels.Pipe#source()
View Full Code Here

        Ruby runtime = context.runtime;
        try {
            Pipe pipe = Pipe.open();

            RubyIO source = new RubyIO(runtime, pipe.source());
            RubyIO sink = new RubyIO(runtime, pipe.sink());

            sink.openFile.getMainStreamSafe().setSync(true);
            return runtime.newArrayNoCopy(new IRubyObject[]{source, sink});
        } catch (BadDescriptorException e) {
            throw runtime.newErrnoEBADFError();
View Full Code Here

        try {
            Pipe pipe = Pipe.open();

            RubyIO source = new RubyIO(runtime, pipe.source());
            source.setEncodingFromOptions(EncodingOption.getEncodingOptionFromString(runtime, modes.toString()));
            RubyIO sink = new RubyIO(runtime, pipe.sink());

//            Encoding ascii8bit = context.runtime.getEncodingService().getAscii8bitEncoding();
//            sink.setupReadWriteEncodings(context, ascii8bit, ascii8bit);

            sink.openFile.getMainStreamSafe().setSync(true);
View Full Code Here

    public PipeImpl() throws IOException {
        if (useNative) {
            Pipe pipe = Pipe.open();
            source = pipe.source();
            sink = pipe.sink();

        } else {
            PipedInputStream pipedIn = new PipedInputStream();
            try {
                pipedOut = new PipedOutputStream(pipedIn);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.