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


Java OutputStreamDataSource类代码示例

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


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

示例1: testCloseDataSourceSingle

import org.globus.ftp.OutputStreamDataSource; //导入依赖的package包/类
public void testCloseDataSourceSingle() throws Exception {

	OutputStreamDataSource sr = new OutputStreamDataSource(512);

	OutputStream out = sr.getOutputStream();
	out.write(1);
	out.flush();
	out.write(2);
	out.flush();
	out.write(3);
	out.flush();

	Buffer buf;

	buf = sr.read();
	assertTrue(buf != null);

	buf = sr.read();
	assertTrue(buf != null);

	sr.close();

	buf = sr.read();

	assertTrue(buf == null);
    }
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:27,代码来源:OutputStreamDataSourceTest.java

示例2: testCloseStreamThead

import org.globus.ftp.OutputStreamDataSource; //导入依赖的package包/类
public void testCloseStreamThead() throws Exception {

	OutputStreamDataSource sr = new OutputStreamDataSource(512);
	
	Thread3 t = new Thread3(sr);
	t.start();

	OutputStream out = sr.getOutputStream();

	out.write(1);
	out.flush();
	out.write(2);
	out.flush();
	out.write(3);
	out.flush();
	out.close();

	t.join(1000*60);

	assertTrue(t.getException() == null);
	assertEquals(3, t.getCount());
    }
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:23,代码来源:OutputStreamDataSourceTest.java

示例3: testCloseStream

import org.globus.ftp.OutputStreamDataSource; //导入依赖的package包/类
public void testCloseStream() throws Exception {

	OutputStreamDataSource sr = new OutputStreamDataSource(512);
	
	OutputStream out = sr.getOutputStream();

	out.write(1);
	out.flush();
	out.write(2);
	out.flush();
	out.write(3);
	out.flush();
	out.close();

	Buffer buf = null;

	buf = sr.read();
	assertTrue(buf != null);

	buf = sr.read();
	assertTrue(buf != null);

	buf = sr.read();
	assertTrue(buf != null);

	buf = sr.read();
	assertTrue(buf == null);
    }
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:29,代码来源:OutputStreamDataSourceTest.java

示例4: testCloseDataSourceMulti

import org.globus.ftp.OutputStreamDataSource; //导入依赖的package包/类
public void testCloseDataSourceMulti() throws Exception {

	OutputStreamDataSource sr = new OutputStreamDataSource(512);

	Thread1 t = new Thread1(sr);
	t.start();

	// give the thread a chance to run
	Thread.sleep(2000);

	sr.close();

	assertEquals(null, t.getBuffer());
	assertEquals(null, t.getException());
	assertEquals(null, sr.read());
    }
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:17,代码来源:OutputStreamDataSourceTest.java

示例5: Thread1

import org.globus.ftp.OutputStreamDataSource; //导入依赖的package包/类
public Thread1(OutputStreamDataSource sr) {
    this.sr = sr;
}
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:4,代码来源:OutputStreamDataSourceTest.java

示例6: testCloseDataSourceStream

import org.globus.ftp.OutputStreamDataSource; //导入依赖的package包/类
public void testCloseDataSourceStream() throws Exception {

	OutputStreamDataSource sr = new OutputStreamDataSource(512);
	
	OutputStream out = sr.getOutputStream();

	Thread2 t = new Thread2(out);
	t.start();

	// give the thread a chance to run
	Thread.sleep(2000);

	sr.close();

	assertTrue(t.getException1() == null);
	assertTrue(t.getException2() != null);
	assertTrue(t.getException2() instanceof EOFException);
	assertTrue(sr.read() == null);
    }
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:20,代码来源:OutputStreamDataSourceTest.java

示例7: Thread3

import org.globus.ftp.OutputStreamDataSource; //导入依赖的package包/类
public Thread3(OutputStreamDataSource sr) {
    this.sr = sr;
}
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:4,代码来源:OutputStreamDataSourceTest.java

示例8: put

import org.globus.ftp.OutputStreamDataSource; //导入依赖的package包/类
/**
      This method performs the actual transfer
    **/
   protected void put(GridFTPClient client, 
	       int localServerMode,
	       int transferType,
	       int transferMode,
	       DataChannelAuthentication dcau,
	       int prot,
	       String fullLocalFile,
	       String fullRemoteFile) 
throws Exception{
client.authenticate(getCredential()); /* use default cred */
client.setProtectionBufferSize(16384);
client.setType(transferType);
client.setMode(transferMode);
	client.setDataChannelAuthentication(dcau);
	client.setDataChannelProtection(prot);

if (localServerMode == Session.SERVER_ACTIVE) {
    client.setPassive();
    client.setLocalActive();
} else {
    if (TestEnv.localServerPort == TestEnv.UNDEFINED) {
	client.setLocalPassive(); 
    } else {
	client.setLocalPassive(TestEnv.localServerPort, 
			       FTPServerFacade.DEFAULT_QUEUE);
    }
    client.setActive();
}

logger.debug("sending file " + fullLocalFile);
OutputStreamDataSource source = new OutputStreamDataSource(2048);

TransferState s = client.asynchPut(fullRemoteFile,
				   source,
				   null);

FileInputStream in = new FileInputStream(fullLocalFile);
OutputStream out = source.getOutputStream();
byte [] buff = new byte[2048];
int bytes = 0;
while ( (bytes = in.read(buff)) != -1 ) {
    out.write(buff, 0, bytes);
    logger.debug("wrote: " + bytes);
}
out.close();
in.close();

s.waitForEnd();
   }
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:53,代码来源:GridFTPClient2PartyAsynchTransferTest.java


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