當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。