• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NullInputStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: fileNested

import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Test
public void fileNested() throws Exception {
	waitForWorkspaceChanges(() -> {
		project.getFolder("/folder").create(true, true, null);
		project.getFolder("/folder/deep/").create(true, true, null);
		IFile file = project.getFile("/folder/deep/myFile.ext");
		file.create(new NullInputStream(0), true, null);
	});

	URI uri = URI.createPlatformResourceURI("/myProject/folder/deep/myFile.ext", true);
	IResource iResource = UriUtils.toIResource(uri);

	assertTrue(iResource instanceof IFile);
	assertTrue(iResource.exists());
	assertEquals("/myProject/folder/deep/myFile.ext", iResource.getFullPath().toString());
}
 
开发者ID:enikao,项目名称:eclipse-commons,代码行数:17,代码来源:TestToIResourcePositive.java


示例2: fileSlashesExcess

import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Test
public void fileSlashesExcess() throws Exception {
	waitForWorkspaceChanges(() -> {
		project.getFolder("/folder").create(true, true, null);
		project.getFolder("/folder/deep/").create(true, true, null);
		IFile file = project.getFile("/folder/deep/myFile.ext");
		file.create(new NullInputStream(0), true, null);
	});

	URI uri = URI.createPlatformResourceURI("////myProject///folder///deep/myFile.ext//", true);
	IResource iResource = UriUtils.toIResource(uri);

	assertTrue(iResource instanceof IFile);
	assertTrue(iResource.exists());
	assertEquals("/myProject/folder/deep/myFile.ext", iResource.getFullPath().toString());
}
 
开发者ID:enikao,项目名称:eclipse-commons,代码行数:17,代码来源:TestToIResourcePositive.java


示例3: testWriteZeroLength

import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Test
public void testWriteZeroLength() throws Exception {
    final Host host = new Host(new SDSProtocol(), "duck.ssp-europe.eu", new Credentials(
            System.getProperties().getProperty("sds.user"), System.getProperties().getProperty("sds.key")
    ));
    final SDSSession session = new SDSSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path room = new SDSDirectoryFeature(session).mkdir(
            new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), null, new TransferStatus());
    final TransferStatus status = new TransferStatus();
    final Path test = new Path(room, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
    final SDSMultipartWriteFeature writer = new SDSMultipartWriteFeature(session);
    final HttpResponseOutputStream<VersionId> out = writer.write(test, status, new DisabledConnectionCallback());
    assertNotNull(out);
    new StreamCopier(status, status).transfer(new NullInputStream(0L), out);
    final VersionId version = out.getStatus();
    assertNotNull(version);
    assertTrue(new DefaultFindFeature(session).find(test));
    new SDSDeleteFeature(session).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:23,代码来源:SDSMultipartWriteFeatureTest.java


示例4: read

import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Override
public synchronized int read(final byte[] chunk, final Long offset) throws IOException {
    final RandomAccessFile file = random();
    if(offset < file.length()) {
        file.seek(offset);
        if(chunk.length + offset > file.length()) {
            return file.read(chunk, 0, (int) (file.length() - offset));
        }
        else {
            return file.read(chunk, 0, chunk.length);
        }
    }
    else {
        final NullInputStream nullStream = new NullInputStream(length);
        if(nullStream.available() > 0) {
            nullStream.skip(offset);
            return nullStream.read(chunk, 0, chunk.length);
        }
        else {
            return IOUtils.EOF;
        }
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:24,代码来源:FileBuffer.java


示例5: setUp

import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    releasableInputStream = new ReleasableInputStream(new NullInputStream(2048), () -> wasCalled.set(true));
    failedReleasableInputStream = new ReleasableInputStream(new InputStream() {

        @Override
        public int read() throws IOException {
            throw new IOException("Oops");
        }

        @Override
        public int available() throws IOException {
            throw new IOException("Oops");
        }

        @Override
        public synchronized void mark(int readlimit) {
            throw new RuntimeException("Oops");
        }
    }, () -> wasCalled.set(true));
}
 
开发者ID:Talend,项目名称:data-prep,代码行数:22,代码来源:ReleasableInputStreamTest.java


示例6: useFileCollector

import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
String useFileCollector(FileCollectorAbstract fileCollector) throws Exception {
	CachingClassLoaderConfiguration classLoaderConfiguration = new CachingClassLoaderConfiguration();
	classLoaderConfiguration.setFileCollector(fileCollector);
	classLoaderConfiguration.setLocalFirst(false);
	classLoaderConfiguration.setCacheType(CacheType.NoCache, true);
	classLoaderConfiguration.getCacheConfiguration().setCacheFolder("target"+File.separator +"classLoaderCache");
	startup(classLoaderConfiguration);

	try(at.ac.tuwien.infosys.jcloudscale.classLoader.caching.RemoteClassLoader classLoader = (at.ac.tuwien.infosys.jcloudscale.classLoader.caching.RemoteClassLoader)classLoaderConfiguration.createClassLoader())
	{
		assertSame(at.ac.tuwien.infosys.jcloudscale.classLoader.caching.RemoteClassLoader.class, classLoader.getClass());

		InputStream stream = getInputStream(classLoader);
		return IOUtils.toString(firstNonNull(stream, new NullInputStream(0)));
	}
}
 
开发者ID:xLeitix,项目名称:jcloudscale,代码行数:17,代码来源:ClassLoaderTest.java


示例7: testWriteGiantRecord

import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
public void testWriteGiantRecord() throws IOException {
    PrintStream dummyStream = new PrintStream(new NullOutputStream());
    ARCWriter arcWriter = 
        new ARCWriter(
                SERIAL_NO,
                dummyStream,
                new File("dummy"),
                new WriterPoolSettingsData(
                        "", 
                        "", 
                        -1, 
                        false, 
                        null, 
                        null));
    assertNotNull(arcWriter);

    // Start the record with an arbitrary 14-digit date per RFC2540
    long now = System.currentTimeMillis();
    long recordLength = org.apache.commons.io.FileUtils.ONE_GB * 3;
   
    arcWriter.write("dummy:uri", "application/octet-stream",
        "0.1.2.3", now, recordLength, new NullInputStream(recordLength));
    arcWriter.close();
}
 
开发者ID:iipc,项目名称:webarchive-commons,代码行数:25,代码来源:ARCWriterTest.java


示例8: testSaveEmailAndNotify_correct_config_invalid_input

import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@SuppressWarnings("deprecation")

	// TEST WITH CORRECT CONFIG AND INVALID INPUT
	@Test
	public void testSaveEmailAndNotify_correct_config_invalid_input() throws Exception {
		// GIVEN I have a server accurately configured (relay domains)

		ServerConfiguration serverConfiguration = new ServerConfiguration();

		MailSaver mailSaver = new MailSaver(serverConfiguration);

		serverConfiguration.relayDomains("data.org");

		MailServerModel mailServerModel = new MailServerModel();
		// AND I don't forget to register the mailServerModel
		mailSaver.addObserver(mailServerModel);

		// WHEN I sent a mail
		mailSaver.saveEmailAndNotify(FROM, TO, new NullInputStream(10));

		// THEN
		Assert.assertEquals(1, mailServerModel.getEmailModels().size());
		EmailModel emailModel = mailServerModel.getEmailModels().get(0);
		assertNotNull(emailModel);
		assertEquals("", emailModel.getSubject());

		//
	}
 
开发者ID:sleroy,项目名称:fakesmtp-junit-runner,代码行数:29,代码来源:MailSaverTest.java


示例9: testCloseQuietlyImageInputStreamOpen

import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Test
public void testCloseQuietlyImageInputStreamOpen() {
  final ImageInputStream in =
    new MemoryCacheImageInputStream(new NullInputStream(1000));

  IOUtils.closeQuietly(in);

  try {
    in.close();
    fail();
  }
  catch (IOException e) {
    // This, oddly, the expected behavior of close().
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:16,代码来源:IOUtilsTest.java


示例10: fileSlash

import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Test
public void fileSlash() throws Exception {
	waitForWorkspaceChanges(() -> {
		IFile file = project.getFile("myFile.ext");
		file.create(new NullInputStream(0), true, null);
	});

	URI uri = URI.createPlatformResourceURI("/myProject/myFile.ext/", true);
	IResource iResource = UriUtils.toIResource(uri);

	assertTrue(iResource instanceof IFile);
	assertTrue(iResource.exists());
	assertEquals("/myProject/myFile.ext", iResource.getFullPath().toString());
}
 
开发者ID:enikao,项目名称:eclipse-commons,代码行数:15,代码来源:TestToIResourcePositive.java


示例11: fileDifferentCase

import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Test
public void fileDifferentCase() throws Exception {
	waitForWorkspaceChanges(() -> {
		IFile file = project.getFile("myFile.ext");
		file.create(new NullInputStream(0), true, null);
	});

	URI uri = URI.createPlatformResourceURI("/myProject/MYfILE.ext", true);
	IResource iResource = UriUtils.toIResource(uri);

	assertTrue(iResource instanceof IFile);
	assertFalse(iResource.exists());
	assertEquals("/myProject/MYfILE.ext", iResource.getFullPath().toString());
}
 
开发者ID:enikao,项目名称:eclipse-commons,代码行数:15,代码来源:TestToIResourcePositive.java


示例12: fragment

import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Test
public void fragment() throws Exception {
	waitForWorkspaceChanges(() -> {
		IFile file = project.getFile("myFile.ext");
		file.create(new NullInputStream(0), true, null);
	});

	URI uri = URI.createPlatformResourceURI("/myProject/myFile.ext", true).appendFragment("fragment");
	IResource iResource = UriUtils.toIResource(uri);

	assertTrue(iResource instanceof IFile);
	assertTrue(iResource.exists());
	assertEquals("/myProject/myFile.ext", iResource.getFullPath().toString());
}
 
开发者ID:enikao,项目名称:eclipse-commons,代码行数:15,代码来源:TestToIResourcePositive.java


示例13: query

import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Test
public void query() throws Exception {
	waitForWorkspaceChanges(() -> {
		IFile file = project.getFile("myFile.ext");
		file.create(new NullInputStream(0), true, null);
	});

	URI uri = URI.createPlatformResourceURI("/myProject/myFile.ext", true).appendQuery("query");
	IResource iResource = UriUtils.toIResource(uri);

	assertTrue(iResource instanceof IFile);
	assertTrue(iResource.exists());
	assertEquals("/myProject/myFile.ext", iResource.getFullPath().toString());
}
 
开发者ID:enikao,项目名称:eclipse-commons,代码行数:15,代码来源:TestToIResourcePositive.java


示例14: mkdir

import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Override
public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException {
    if(containerService.isContainer(folder)) {
        return super.mkdir(folder, region, status);
    }
    else {
        if(Checksum.NONE == status.getChecksum()) {
            status.setChecksum(writer.checksum(folder).compute(new NullInputStream(0L), status));
        }
        return super.mkdir(folder, region, status);
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:13,代码来源:SpectraDirectoryFeature.java


示例15: touch

import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Override
public Path touch(final Path file, final TransferStatus status) throws BackgroundException {
    if(Checksum.NONE == status.getChecksum()) {
        status.setChecksum(writer.checksum(file).compute(new NullInputStream(0L), status));
    }
    status.setTimestamp(System.currentTimeMillis());
    final StatusOutputStream<BaseB2Response> out = writer.write(file, status, new DisabledConnectionCallback());
    new DefaultStreamCloser().close(out);
    return new Path(file.getParent(), file.getName(), file.getType(),
        new PathAttributes(file.attributes()).withVersionId(((B2FileResponse) out.getStatus()).getFileId()));
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:12,代码来源:B2TouchFeature.java


示例16: testDecorate

import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Test
public void testDecorate() throws Exception {
    final NullInputStream n = new NullInputStream(1L);
    final SwiftSession session = new SwiftSession(new Host(new SwiftProtocol()));
    assertSame(NullInputStream.class, new SwiftSmallObjectUploadFeature(new SwiftWriteFeature(
            session, new SwiftRegionService(session))).decorate(n, null).getClass());
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:8,代码来源:SwiftSmallObjectUploadFeatureTest.java


示例17: compute

import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Override
public Checksum compute(final InputStream in, final TransferStatus status) throws ChecksumException {
    if(Checksum.NONE == delegate.compute(new NullInputStream(0L), status)) {
        return Checksum.NONE;
    }
    if(null == status.getHeader()) {
        // Write header to be reused in writer
        final Cryptor cryptor = cryptomator.getCryptor();
        final FileHeader header = cryptor.fileHeaderCryptor().create();
        status.setHeader(cryptor.fileHeaderCryptor().encryptHeader(header));
    }
    // Make nonces reusable in case we need to compute a checksum
    status.setNonces(new RotatingNonceGenerator(cryptomator.numberOfChunks(status.getLength())));
    return this.compute(in, status.getOffset(), status.getHeader(), status.getNonces());
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:16,代码来源:CryptoChecksumCompute.java


示例18: touch

import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Override
public Path touch(final Path file, final TransferStatus status) throws BackgroundException {
    if(Checksum.NONE == status.getChecksum()) {
        status.setChecksum(writer.checksum(file).compute(new NullInputStream(0L), status));
    }
    new DefaultStreamCloser().close(writer.write(file, status, new DisabledConnectionCallback()));
    return file;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:9,代码来源:AzureTouchFeature.java


示例19: touch

import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Override
public Path touch(final Path file, final TransferStatus status) throws BackgroundException {
    if(Checksum.NONE == status.getChecksum()) {
        status.setChecksum(writer.checksum(file).compute(new NullInputStream(0L), status));
    }
    status.setLength(0L);
    final StatusOutputStream<StorageObject> out = writer.write(file, status, new DisabledConnectionCallback());
    new DefaultStreamCloser().close(out);
    return new Path(file.getParent(), file.getName(), file.getType(),
            new PathAttributes(file.attributes()).withVersionId(((S3Object) out.getStatus()).getVersionId()));
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:12,代码来源:S3TouchFeature.java


示例20: testDecorate

import org.apache.commons.io.input.NullInputStream; //导入依赖的package包/类
@Test
public void testDecorate() throws Exception {
    final NullInputStream n = new NullInputStream(1L);
    final S3Session session = new S3Session(new Host(new S3Protocol()));
    assertSame(NullInputStream.class, new S3SingleUploadService(session,
            new S3WriteFeature(session, new S3DisabledMultipartService())).decorate(n, null).getClass());
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:8,代码来源:S3SingleUploadServiceTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FloodlightModuleLoader类代码示例发布时间:2022-05-21
下一篇:
Java CreateTxn类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap