当前位置: 首页>>代码示例>>Java>>正文


Java ClosedInputStream类代码示例

本文整理汇总了Java中org.apache.commons.io.input.ClosedInputStream的典型用法代码示例。如果您正苦于以下问题:Java ClosedInputStream类的具体用法?Java ClosedInputStream怎么用?Java ClosedInputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ClosedInputStream类属于org.apache.commons.io.input包,在下文中一共展示了ClosedInputStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getResourceInputStream

import org.apache.commons.io.input.ClosedInputStream; //导入依赖的package包/类
@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;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:17,代码来源:DynamicMetadataResolverAdapter.java

示例2: testPumpInClosed

import org.apache.commons.io.input.ClosedInputStream; //导入依赖的package包/类
@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();
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:26,代码来源:TileProgressPumpTest.java

示例3: testPumpInClosed

import org.apache.commons.io.input.ClosedInputStream; //导入依赖的package包/类
@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());
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:20,代码来源:InputOutputStreamPumpTest.java

示例4: testPumpBothClosed

import org.apache.commons.io.input.ClosedInputStream; //导入依赖的package包/类
@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();
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:18,代码来源:InputOutputStreamPumpTest.java

示例5: toBufferedInputStream

import org.apache.commons.io.input.ClosedInputStream; //导入依赖的package包/类
/**
 * 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));
}
 
开发者ID:fesch,项目名称:Moenagade,代码行数:27,代码来源:ByteArrayOutputStream.java

示例6: toBufferedInputStream

import org.apache.commons.io.input.ClosedInputStream; //导入依赖的package包/类
/**
 * 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));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:ByteArrayOutputStream.java

示例7: toInputStream

import org.apache.commons.io.input.ClosedInputStream; //导入依赖的package包/类
/**
 * 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));
}
 
开发者ID:PuppyRush,项目名称:WidgetStore,代码行数:28,代码来源:ByteArrayOutputStream.java

示例8: testSetInputStreamRunning

import org.apache.commons.io.input.ClosedInputStream; //导入依赖的package包/类
@Test(expected=UnsupportedOperationException.class)
public void testSetInputStreamRunning() {
  final TileProgressPump p = new TPP();
  p.run();

  final InputStream in = new ClosedInputStream();
  p.setInputStream(in);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:9,代码来源:TileProgressPumpTest.java

示例9: testSetInputStreamRunning

import org.apache.commons.io.input.ClosedInputStream; //导入依赖的package包/类
@Test(expected=UnsupportedOperationException.class)
public void testSetInputStreamRunning() {
  final InputOutputStreamPump p = new IOSP();
  p.run();

  final InputStream in = new ClosedInputStream();
  p.setInputStream(in);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:9,代码来源:InputOutputStreamPumpTest.java

示例10: testCloseQuietlyImageInputStreamClosed

import org.apache.commons.io.input.ClosedInputStream; //导入依赖的package包/类
@Test
public void testCloseQuietlyImageInputStreamClosed() throws IOException {
  final ImageInputStream in =
    new MemoryCacheImageInputStream(new ClosedInputStream());
  in.close();

  IOUtils.closeQuietly(in);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:9,代码来源:IOUtilsTest.java

示例11: close

import org.apache.commons.io.input.ClosedInputStream; //导入依赖的package包/类
@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;
}
 
开发者ID:subes,项目名称:invesdwin-util,代码行数:9,代码来源:ADelegateInputStream.java

示例12: testSetInputStreamNotRunning

import org.apache.commons.io.input.ClosedInputStream; //导入依赖的package包/类
@Test
public void testSetInputStreamNotRunning() {
  final TileProgressPump p = new TPP();
  final InputStream in = new ClosedInputStream();
  p.setInputStream(in);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:7,代码来源:TileProgressPumpTest.java

示例13: testSetInputStreamNotRunning

import org.apache.commons.io.input.ClosedInputStream; //导入依赖的package包/类
@Test
public void testSetInputStreamNotRunning() {
  final InputOutputStreamPump p = new InputOutputStreamPump();
  final InputStream in = new ClosedInputStream();
  p.setInputStream(in);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:7,代码来源:InputOutputStreamPumpTest.java

示例14: resolveEntity

import org.apache.commons.io.input.ClosedInputStream; //导入依赖的package包/类
@Override
public InputSource resolveEntity(String publicId, String systemId) {
  return new InputSource(ClosedInputStream.CLOSED_INPUT_STREAM);
}
 
开发者ID:lucidworks,项目名称:hadoop-solr,代码行数:5,代码来源:EmptyEntityResolver.java

示例15: isClosed

import org.apache.commons.io.input.ClosedInputStream; //导入依赖的package包/类
public boolean isClosed() {
    return delegate == ClosedInputStream.CLOSED_INPUT_STREAM;
}
 
开发者ID:subes,项目名称:invesdwin-util,代码行数:4,代码来源:ADelegateInputStream.java


注:本文中的org.apache.commons.io.input.ClosedInputStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。