Java 类org.apache.commons.io.input.ClosedInputStream 实例源码

项目:cas-5.1.0    文件:DynamicMetadataResolverAdapter.java   
@Override
protected InputStream getResourceInputStream(final Resource resource, final String entityId) throws IOException {
    if (resource instanceof UrlResource && resource.getURL().toExternalForm().toLowerCase().endsWith("/entities/")) {
        final String encodedId = EncodingUtils.urlEncode(entityId);
        final URL url = new URL(resource.getURL().toExternalForm().concat(encodedId));

        LOGGER.debug("Locating metadata input stream for [{}] via [{}]", encodedId, url);
        final HttpURLConnection httpcon = (HttpURLConnection) url.openConnection();
        httpcon.setDoOutput(true);
        httpcon.addRequestProperty("Accept", "*/*");
        httpcon.setRequestMethod("GET");
        httpcon.connect();
        return httpcon.getInputStream();
    }
    return ClosedInputStream.CLOSED_INPUT_STREAM;
}
项目:VASSAL-src    文件:TileProgressPumpTest.java   
@Test
@SuppressWarnings("unchecked")
public void testPumpInClosed() {
  final InputStream in = new ClosedInputStream();

  final EventListener<String> nl = context.mock(EventListener.class, "nl");
  final EventListener<Integer> pl = context.mock(EventListener.class, "pl");
  final EventListener<IOException> el =
    context.mock(EventListener.class, "el");

  context.checking(new Expectations() {
    {
      never(nl).receive(with(any(Object.class)),
                        with(any(String.class)));
      never(pl).receive(with(any(Object.class)),
                        with(any(Integer.class)));
      never(el).receive(with(any(Object.class)),
                        with(any(IOException.class)));
    }
  });

  final TileProgressPump p = new TileProgressPump(nl, pl, el);
  p.setInputStream(in);
  p.run();
}
项目:VASSAL-src    文件:InputOutputStreamPumpTest.java   
@Test
@SuppressWarnings("unchecked")
public void testPumpInClosed() {
  final InputStream in = new ClosedInputStream();
  final ByteArrayOutputStream out = new ByteArrayOutputStream();

  final EventListener<IOException> el = context.mock(EventListener.class);
  context.checking(new Expectations() {
    {
      never(el).receive(with(any(Object.class)),
                        with(any(IOException.class)));
    }
  });

  final InputOutputStreamPump p = new InputOutputStreamPump(in, out, el);
  p.run();

  assertArrayEquals(new byte[0], out.toByteArray());
}
项目:VASSAL-src    文件:InputOutputStreamPumpTest.java   
@Test
@SuppressWarnings("unchecked")
public void testPumpBothClosed() {
  final InputStream in = new ClosedInputStream();
  final OutputStream out = new ClosedOutputStream();

  final EventListener<IOException> el = context.mock(EventListener.class);
  context.checking(new Expectations() {
    {
      never(el).receive(with(any(Object.class)),
                        with(any(IOException.class)));
    }
  });

  final InputOutputStreamPump p = new InputOutputStreamPump(in, out, el);
  p.run();
}
项目:Moenagade    文件:ByteArrayOutputStream.java   
/**
 * Gets the current contents of this byte stream as a Input Stream. The
 * returned stream is backed by buffers of <code>this</code> stream,
 * avoiding memory allocation and copy, thus saving space and time.<br>
 * 
 * @return the current contents of this output stream.
 * @see java.io.ByteArrayOutputStream#toByteArray()
 * @see #reset()
 * @since Commons IO 2.0
 */
private InputStream toBufferedInputStream() {
    int remaining = count;
    if (remaining == 0) {
        return new ClosedInputStream();
    }
    List<ByteArrayInputStream> list = new ArrayList<ByteArrayInputStream>(buffers.size());
    for (byte[] buf : buffers) {
        int c = Math.min(buf.length, remaining);
        list.add(new ByteArrayInputStream(buf, 0, c));
        remaining -= c;
        if (remaining == 0) {
            break;
        }
    }
    return new SequenceInputStream(Collections.enumeration(list));
}
项目:lams    文件:ByteArrayOutputStream.java   
/**
 * Gets the current contents of this byte stream as a Input Stream. The
 * returned stream is backed by buffers of <code>this</code> stream,
 * avoiding memory allocation and copy, thus saving space and time.<br>
 * 
 * @return the current contents of this output stream.
 * @see java.io.ByteArrayOutputStream#toByteArray()
 * @see #reset()
 * @since 2.0
 */
private InputStream toBufferedInputStream() {
    int remaining = count;
    if (remaining == 0) {
        return new ClosedInputStream();
    }
    List<ByteArrayInputStream> list = new ArrayList<ByteArrayInputStream>(buffers.size());
    for (byte[] buf : buffers) {
        int c = Math.min(buf.length, remaining);
        list.add(new ByteArrayInputStream(buf, 0, c));
        remaining -= c;
        if (remaining == 0) {
            break;
        }
    }
    return new SequenceInputStream(Collections.enumeration(list));
}
项目:WidgetStore    文件:ByteArrayOutputStream.java   
/**
 * Gets the current contents of this byte stream as a Input Stream. The
 * returned stream is backed by buffers of <code>this</code> stream,
 * avoiding memory allocation and copy, thus saving space and time.<br>
 *
 * @return the current contents of this output stream.
 * @see java.io.ByteArrayOutputStream#toByteArray()
 * @see #reset()
 * @since 2.5
 */
public synchronized InputStream toInputStream() {
    int remaining = count;
    if (remaining == 0) {
        return new ClosedInputStream();
    }
    final List<ByteArrayInputStream> list = new ArrayList<ByteArrayInputStream>(buffers.size());
    for (final byte[] buf : buffers) {
        final int c = Math.min(buf.length, remaining);
        list.add(new ByteArrayInputStream(buf, 0, c));
        remaining -= c;
        if (remaining == 0) {
            break;
        }
    }
    reuseBuffers = false;
    return new SequenceInputStream(Collections.enumeration(list));
}
项目:JAATP    文件:ByteArrayOutputStream.java   
/**
 * Gets the current contents of this byte stream as a Input Stream. The
 * returned stream is backed by buffers of <code>this</code> stream,
 * avoiding memory allocation and copy, thus saving space and time.<br>
 *
 * @return the current contents of this output stream.
 * @see java.io.ByteArrayOutputStream#toByteArray()
 * @see #reset()
 * @since 2.5
 */
public synchronized InputStream toInputStream() {
    int remaining = count;
    if (remaining == 0) {
        return new ClosedInputStream();
    }
    final List<ByteArrayInputStream> list = new ArrayList<ByteArrayInputStream>(buffers.size());
    for (final byte[] buf : buffers) {
        final int c = Math.min(buf.length, remaining);
        list.add(new ByteArrayInputStream(buf, 0, c));
        remaining -= c;
        if (remaining == 0) {
            break;
        }
    }
    reuseBuffers = false;
    return new SequenceInputStream(Collections.enumeration(list));
}
项目:android-openvpn-settings    文件:ByteArrayOutputStream.java   
/**
 * Gets the current contents of this byte stream as a Input Stream. The
 * returned stream is backed by buffers of <code>this</code> stream,
 * avoiding memory allocation and copy, thus saving space and time.<br>
 * 
 * @return the current contents of this output stream.
 * @see java.io.ByteArrayOutputStream#toByteArray()
 * @see #reset()
 * @since Commons IO 2.0
 */
private InputStream toBufferedInputStream() {
    int remaining = count;
    if (remaining == 0) {
        return new ClosedInputStream();
    }
    List<ByteArrayInputStream> list = new ArrayList<ByteArrayInputStream>(buffers.size());
    for (byte[] buf : buffers) {
        int c = Math.min(buf.length, remaining);
        list.add(new ByteArrayInputStream(buf, 0, c));
        remaining -= c;
        if (remaining == 0) {
            break;
        }
    }
    return new SequenceInputStream(Collections.enumeration(list));
}
项目:VectorAttackScanner    文件:ByteArrayOutputStream.java   
/**
 * Gets the current contents of this byte stream as a Input Stream. The
 * returned stream is backed by buffers of <code>this</code> stream,
 * avoiding memory allocation and copy, thus saving space and time.<br>
 * 
 * @return the current contents of this output stream.
 * @see java.io.ByteArrayOutputStream#toByteArray()
 * @see #reset()
 * @since 2.0
 */
private InputStream toBufferedInputStream() {
    int remaining = count;
    if (remaining == 0) {
        return new ClosedInputStream();
    }
    List<ByteArrayInputStream> list = new ArrayList<ByteArrayInputStream>(buffers.size());
    for (byte[] buf : buffers) {
        int c = Math.min(buf.length, remaining);
        list.add(new ByteArrayInputStream(buf, 0, c));
        remaining -= c;
        if (remaining == 0) {
            break;
        }
    }
    return new SequenceInputStream(Collections.enumeration(list));
}
项目:vassal    文件:TileProgressPumpTest.java   
@Test
@SuppressWarnings("unchecked")
public void testPumpInClosed() {
  final InputStream in = new ClosedInputStream();

  final EventListener<String> nl = context.mock(EventListener.class, "nl");
  final EventListener<Integer> pl = context.mock(EventListener.class, "pl");
  final EventListener<IOException> el =
    context.mock(EventListener.class, "el");

  context.checking(new Expectations() {
    {
      never(nl).receive(with(any(Object.class)),
                        with(any(String.class)));
      never(pl).receive(with(any(Object.class)),
                        with(any(Integer.class)));
      never(el).receive(with(any(Object.class)),
                        with(any(IOException.class)));
    }
  });

  final TileProgressPump p = new TileProgressPump(nl, pl, el);
  p.setInputStream(in);
  p.run();
}
项目:vassal    文件:InputOutputStreamPumpTest.java   
@Test
@SuppressWarnings("unchecked")
public void testPumpInClosed() {
  final InputStream in = new ClosedInputStream();
  final ByteArrayOutputStream out = new ByteArrayOutputStream();

  final EventListener<IOException> el = context.mock(EventListener.class);
  context.checking(new Expectations() {
    {
      never(el).receive(with(any(Object.class)),
                        with(any(IOException.class)));
    }
  });

  final InputOutputStreamPump p = new InputOutputStreamPump(in, out, el);
  p.run();

  assertArrayEquals(new byte[0], out.toByteArray());
}
项目:vassal    文件:InputOutputStreamPumpTest.java   
@Test
@SuppressWarnings("unchecked")
public void testPumpBothClosed() {
  final InputStream in = new ClosedInputStream();
  final OutputStream out = new ClosedOutputStream();

  final EventListener<IOException> el = context.mock(EventListener.class);
  context.checking(new Expectations() {
    {
      never(el).receive(with(any(Object.class)),
                        with(any(IOException.class)));
    }
  });

  final InputOutputStreamPump p = new InputOutputStreamPump(in, out, el);
  p.run();
}
项目:dota2-sound-editor    文件:ByteArrayOutputStream.java   
/**
 * Gets the current contents of this byte stream as a Input Stream. The
 * returned stream is backed by buffers of <code>this</code> stream,
 * avoiding memory allocation and copy, thus saving space and time.<br>
 * 
 * @return the current contents of this output stream.
 * @see java.io.ByteArrayOutputStream#toByteArray()
 * @see #reset()
 * @since 2.0
 */
private InputStream toBufferedInputStream() {
    int remaining = count;
    if (remaining == 0) {
        return new ClosedInputStream();
    }
    List<ByteArrayInputStream> list = new ArrayList<ByteArrayInputStream>(buffers.size());
    for (byte[] buf : buffers) {
        int c = Math.min(buf.length, remaining);
        list.add(new ByteArrayInputStream(buf, 0, c));
        remaining -= c;
        if (remaining == 0) {
            break;
        }
    }
    return new SequenceInputStream(Collections.enumeration(list));
}
项目:My-Wallet-Android    文件:ByteArrayOutputStream.java   
/**
 * Gets the current contents of this byte stream as a Input Stream. The
 * returned stream is backed by buffers of <code>this</code> stream,
 * avoiding memory allocation and copy, thus saving space and time.<br>
 * 
 * @return the current contents of this output stream.
 * @see java.io.ByteArrayOutputStream#toByteArray()
 * @see #reset()
 * @since 2.0
 */
private InputStream toBufferedInputStream() {
    int remaining = count;
    if (remaining == 0) {
        return new ClosedInputStream();
    }
    List<ByteArrayInputStream> list = new ArrayList<ByteArrayInputStream>(buffers.size());
    for (byte[] buf : buffers) {
        int c = Math.min(buf.length, remaining);
        list.add(new ByteArrayInputStream(buf, 0, c));
        remaining -= c;
        if (remaining == 0) {
            break;
        }
    }
    return new SequenceInputStream(Collections.enumeration(list));
}
项目:Corporatique    文件:ByteArrayOutputStream.java   
/**
 * Gets the current contents of this byte stream as a Input Stream. The
 * returned stream is backed by buffers of <code>this</code> stream,
 * avoiding memory allocation and copy, thus saving space and time.<br>
 * 
 * @return the current contents of this output stream.
 * @see java.io.ByteArrayOutputStream#toByteArray()
 * @see #reset()
 * @since 2.0
 */
private InputStream toBufferedInputStream() {
    int remaining = count;
    if (remaining == 0) {
        return new ClosedInputStream();
    }
    List<ByteArrayInputStream> list = new ArrayList<ByteArrayInputStream>(buffers.size());
    for (byte[] buf : buffers) {
        int c = Math.min(buf.length, remaining);
        list.add(new ByteArrayInputStream(buf, 0, c));
        remaining -= c;
        if (remaining == 0) {
            break;
        }
    }
    return new SequenceInputStream(Collections.enumeration(list));
}
项目:KJBE    文件:ByteArrayOutputStream.java   
/**
 * Gets the current contents of this byte stream as a Input Stream. The
 * returned stream is backed by buffers of <code>this</code> stream,
 * avoiding memory allocation and copy, thus saving space and time.<br>
 * 
 * @return the current contents of this output stream.
 * @see java.io.ByteArrayOutputStream#toByteArray()
 * @see #reset()
 * @since Commons IO 2.0
 */
private InputStream toBufferedInputStream() {
    int remaining = count;
    if (remaining == 0) {
        return new ClosedInputStream();
    }
    List<ByteArrayInputStream> list = new ArrayList<ByteArrayInputStream>(buffers.size());
    for (byte[] buf : buffers) {
        int c = Math.min(buf.length, remaining);
        list.add(new ByteArrayInputStream(buf, 0, c));
        remaining -= c;
        if (remaining == 0) {
            break;
        }
    }
    return new SequenceInputStream(Collections.enumeration(list));
}
项目:VASSAL-src    文件:TileProgressPumpTest.java   
@Test(expected=UnsupportedOperationException.class)
public void testSetInputStreamRunning() {
  final TileProgressPump p = new TPP();
  p.run();

  final InputStream in = new ClosedInputStream();
  p.setInputStream(in);
}
项目:VASSAL-src    文件:InputOutputStreamPumpTest.java   
@Test(expected=UnsupportedOperationException.class)
public void testSetInputStreamRunning() {
  final InputOutputStreamPump p = new IOSP();
  p.run();

  final InputStream in = new ClosedInputStream();
  p.setInputStream(in);
}
项目:VASSAL-src    文件:IOUtilsTest.java   
@Test
public void testCloseQuietlyImageInputStreamClosed() throws IOException {
  final ImageInputStream in =
    new MemoryCacheImageInputStream(new ClosedInputStream());
  in.close();

  IOUtils.closeQuietly(in);
}
项目:invesdwin-util    文件:ADelegateInputStream.java   
@Override
public void close() throws IOException {
    if (delegate != null) {
        delegate.close();
    }
    //forget the reference to original inputstream to potentially free some memory
    delegate = ClosedInputStream.CLOSED_INPUT_STREAM;
}
项目:vassal    文件:TileProgressPumpTest.java   
@Test(expected=UnsupportedOperationException.class)
public void testSetInputStreamRunning() {
  final TileProgressPump p = new TPP();
  p.run();

  final InputStream in = new ClosedInputStream();
  p.setInputStream(in);
}
项目:vassal    文件:InputOutputStreamPumpTest.java   
@Test(expected=UnsupportedOperationException.class)
public void testSetInputStreamRunning() {
  final InputOutputStreamPump p = new IOSP();
  p.run();

  final InputStream in = new ClosedInputStream();
  p.setInputStream(in);
}
项目:vassal    文件:IOUtilsTest.java   
@Test
public void testCloseQuietlyImageInputStreamClosed() throws IOException {
  final ImageInputStream in =
    new MemoryCacheImageInputStream(new ClosedInputStream());
  in.close();

  IOUtils.closeQuietly(in);
}
项目:VASSAL-src    文件:TileProgressPumpTest.java   
@Test
public void testSetInputStreamNotRunning() {
  final TileProgressPump p = new TPP();
  final InputStream in = new ClosedInputStream();
  p.setInputStream(in);
}
项目:VASSAL-src    文件:InputOutputStreamPumpTest.java   
@Test
public void testSetInputStreamNotRunning() {
  final InputOutputStreamPump p = new InputOutputStreamPump();
  final InputStream in = new ClosedInputStream();
  p.setInputStream(in);
}
项目:hadoop-solr    文件:EmptyEntityResolver.java   
@Override
public InputSource resolveEntity(String publicId, String systemId) {
  return new InputSource(ClosedInputStream.CLOSED_INPUT_STREAM);
}
项目:hadoop-solr    文件:EmptyEntityResolver.java   
@Override
public InputStream resolveEntity(String publicId, String systemId, String baseURI,
    String namespace) {
  return ClosedInputStream.CLOSED_INPUT_STREAM;
}
项目:invesdwin-util    文件:ADelegateInputStream.java   
public boolean isClosed() {
    return delegate == ClosedInputStream.CLOSED_INPUT_STREAM;
}
项目:search    文件:EmptyEntityResolver.java   
@Override
public InputSource resolveEntity(String publicId, String systemId) {
  return new InputSource(ClosedInputStream.CLOSED_INPUT_STREAM);
}
项目:search    文件:EmptyEntityResolver.java   
@Override
public InputStream resolveEntity(String publicId, String systemId, String baseURI, String namespace) {
  return ClosedInputStream.CLOSED_INPUT_STREAM;
}
项目:vassal    文件:TileProgressPumpTest.java   
@Test
public void testSetInputStreamNotRunning() {
  final TileProgressPump p = new TPP();
  final InputStream in = new ClosedInputStream();
  p.setInputStream(in);
}
项目:vassal    文件:InputOutputStreamPumpTest.java   
@Test
public void testSetInputStreamNotRunning() {
  final InputOutputStreamPump p = new InputOutputStreamPump();
  final InputStream in = new ClosedInputStream();
  p.setInputStream(in);
}
项目:NYBC    文件:EmptyEntityResolver.java   
@Override
public InputSource resolveEntity(String publicId, String systemId) {
  return new InputSource(ClosedInputStream.CLOSED_INPUT_STREAM);
}
项目:NYBC    文件:EmptyEntityResolver.java   
@Override
public InputStream resolveEntity(String publicId, String systemId, String baseURI, String namespace) {
  return ClosedInputStream.CLOSED_INPUT_STREAM;
}
项目:search-core    文件:EmptyEntityResolver.java   
@Override
public InputSource resolveEntity(String publicId, String systemId) {
  return new InputSource(ClosedInputStream.CLOSED_INPUT_STREAM);
}
项目:search-core    文件:EmptyEntityResolver.java   
@Override
public InputStream resolveEntity(String publicId, String systemId, String baseURI, String namespace) {
  return ClosedInputStream.CLOSED_INPUT_STREAM;
}
项目:read-open-source-code    文件:EmptyEntityResolver.java   
@Override
public InputSource resolveEntity(String publicId, String systemId) {
  return new InputSource(ClosedInputStream.CLOSED_INPUT_STREAM);
}
项目:read-open-source-code    文件:EmptyEntityResolver.java   
@Override
public InputStream resolveEntity(String publicId, String systemId, String baseURI, String namespace) {
  return ClosedInputStream.CLOSED_INPUT_STREAM;
}
项目:read-open-source-code    文件:EmptyEntityResolver.java   
@Override
public InputSource resolveEntity(String publicId, String systemId) {
  return new InputSource(ClosedInputStream.CLOSED_INPUT_STREAM);
}