當前位置: 首頁>>代碼示例>>Java>>正文


Java FileObject.close方法代碼示例

本文整理匯總了Java中org.apache.commons.vfs2.FileObject.close方法的典型用法代碼示例。如果您正苦於以下問題:Java FileObject.close方法的具體用法?Java FileObject.close怎麽用?Java FileObject.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.vfs2.FileObject的用法示例。


在下文中一共展示了FileObject.close方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: close

import org.apache.commons.vfs2.FileObject; //導入方法依賴的package包/類
@Override
public void close(FileObject fileObject) {
    try {
        fileObject.close();
    } catch (FileSystemException e) {
        e.printStackTrace();
    }
}
 
開發者ID:geetools,項目名稱:geeCommerce-Java-Shop-Software-and-PIM,代碼行數:9,代碼來源:DefaultVfsHelper.java

示例2: writeToSFTP

import org.apache.commons.vfs2.FileObject; //導入方法依賴的package包/類
protected void writeToSFTP(String filename, int random_num) {
	
	String connectionStr = baseConnectionStr + "/" + filename;
       if(debug) System.err.println(connectionStr);
	
	try {
           // Create remote file object
           FileObject remoteFile = manager.resolveFile(connectionStr, fileSystemOptions);
           FileContent fc = remoteFile.getContent();
           OutputStream ostream = fc.getOutputStream();
		if(ostream==null) {
			throw new IOException("Error opening output stream to SFTP");
		}
		// Write content to file
   		PrintWriter pw = new PrintWriter(ostream);
   		pw.format("%06d\n",random_num);
		pw.close();
		// Cleanup
		if (remoteFile != null) remoteFile.close();
	} catch (Exception e) {
		e.printStackTrace();
	}
	
	/**
	// Here's an alternate approach that creates a local file and then copies the
	// local file to remote directory
	// Create the local file
	File local_file = new File("C:\\TEMP\\TEST",filename);
	try {
	    FileWriter fw = new FileWriter(local_file,false);
	    PrintWriter pw = new PrintWriter(fw);
		// Write out the index and a random number to the file
		pw.format("%06d\n",random_num);
		pw.close();
	} catch (Exception e) {
       	e.printStackTrace();
       }
	// Copy the local file to remote SFTP server
       try {
           // Create local file object
           FileObject localFile = manager.resolveFile(local_file.getAbsolutePath());
           // Create remote file object
           FileObject remoteFile = manager.resolveFile(connectionStr, fileSystemOptions);
           // Copy local file to SFTP server
           remoteFile.copyFrom(localFile, Selectors.SELECT_SELF);
       } catch (Exception e) {
       	e.printStackTrace();
       }
       **/
	
}
 
開發者ID:cycronix,項目名稱:cloudturbine,代碼行數:52,代碼來源:FilePumpWorker.java


注:本文中的org.apache.commons.vfs2.FileObject.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。