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


Java IOUtils.closeQuietly方法代碼示例

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


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

示例1: docxToHtml

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
/**
 * 把docx轉成html
 * @param docxFilePath
 * @param htmlPath
 * @throws Exception
 */
public static void docxToHtml(String docxFilePath, String htmlPath) throws Exception {
	OutputStream output = null;
	try {
		//
		WordprocessingMLPackage wmlPackage = WordprocessingMLPackage.load(new File(docxFilePath));

		WMLPACKAGE_BUILDER.configChineseFonts(wmlPackage).configSimSunFont(wmlPackage);
		
		WMLPACKAGE_WRITER.writeToHtml(wmlPackage, htmlPath);

	} catch (Exception ex) {
		ex.printStackTrace();
	} finally {
		IOUtils.closeQuietly(output);
	}

}
 
開發者ID:vindell,項目名稱:docx4j-template,代碼行數:24,代碼來源:Docx4jUtils.java

示例2: saveReportFile

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
public void saveReportFile(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	String file=req.getParameter("file");
	file=ReportUtils.decodeFileName(file);
	String content=req.getParameter("content");
	ReportProvider targetReportProvider=null;
	for(ReportProvider provider:reportProviders){
		if(file.startsWith(provider.getPrefix())){
			targetReportProvider=provider;
			break;
		}
	}
	if(targetReportProvider==null){
		throw new ReportDesignException("File ["+file+"] not found available report provider.");
	}
	targetReportProvider.saveReport(file, content);
	InputStream inputStream=IOUtils.toInputStream(content,"utf-8");
	ReportDefinition reportDef=reportParser.parse(inputStream, file);
	reportRender.rebuildReportDefinition(reportDef);
	CacheUtils.cacheReportDefinition(file, reportDef);
	IOUtils.closeQuietly(inputStream);
}
 
開發者ID:youseries,項目名稱:ureport,代碼行數:22,代碼來源:DesignerServletAction.java

示例3: unLockQueue

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
private void unLockQueue(String queueID) {
    if (locked.get() == null) {
        return;
    }
    if (locked.get().decrementAndGet() > 0) {
        return;
    }
    Jedis jedis = jedisPool.getResource();
    try {
        jedis.del(makeRedisLockKey(queueID));
        locked.remove();
    } finally {
        IOUtils.closeQuietly(jedis);
    }
}
 
開發者ID:virjar,項目名稱:vscrawler,代碼行數:16,代碼來源:JedisQueueStore.java

示例4: sendFavicon

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
private void sendFavicon(HttpServletResponse response) throws IOException
{
	InputStream fis = null;
	OutputStream out = null;
	try
	{
		response.setContentType("image/x-icon");
		fis = WebServlet.class.getResourceAsStream("/resources/icon.ico");
		out = response.getOutputStream();
		IOUtils.copy(fis, out);
	}
	finally
	{
		IOUtils.closeQuietly(out);
		IOUtils.closeQuietly(fis);
	}
	return;
}
 
開發者ID:PolyphasicDevTeam,項目名稱:NoMoreOversleeps,代碼行數:19,代碼來源:WebServlet.java

示例5: write

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
@Override
public void write(final S item, final Local file) throws AccessDeniedException {
    final String content = item.<NSDictionary>serialize(SerializerFactory.get()).toXMLPropertyList();
    final OutputStream out = file.getOutputStream(false);
    try {
        IOUtils.write(content, out, Charset.forName("UTF-8"));
    }
    catch(IOException e) {
        throw new AccessDeniedException(String.format("Cannot create file %s", file.getAbsolute()), e);
    }
    finally {
        IOUtils.closeQuietly(out);
    }
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:15,代碼來源:PlistWriter.java

示例6: copyStreamToJar

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
protected void copyStreamToJar(InputStream zin, ZipOutputStream out, String currentName, long fileTime) throws IOException {
    // Create new entry for zip file.

    ZipEntry newEntry = new ZipEntry(currentName);
    // Make sure there is date and time set.
    if (fileTime != -1) {
        newEntry.setTime(fileTime); // If found set it into output file.
    }
    out.putNextEntry(newEntry);
    if (zin != null) {
        IOUtils.copy(zin, out);
    }
    IOUtils.closeQuietly(zin);

}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:16,代碼來源:ClazzBasicHandler.java

示例7: tryExtractSparkLibZip

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
private static URL[] tryExtractSparkLibZip(String sparkLibZipPath, String extractTo) throws IOException {
    java.util.zip.ZipFile zipFile = new ZipFile(sparkLibZipPath);
    List<URL> urls = new ArrayList<>();

    try {
        Enumeration<? extends ZipEntry> entries = zipFile.entries();
        while (entries.hasMoreElements()) {
            ZipEntry entry = entries.nextElement();
            File entryDestination = new File(extractTo, entry.getName());
            urls.add(entryDestination.toURI().toURL());
            if (entry.isDirectory()) {
                entryDestination.mkdirs();
            } else {
                entryDestination.getParentFile().mkdirs();
                InputStream in = zipFile.getInputStream(entry);
                OutputStream out = new FileOutputStream(entryDestination);
                IOUtils.copy(in, out);
                IOUtils.closeQuietly(in);
                out.close();
            }
        }
    } finally {
        zipFile.close();
    }

    return urls.toArray(new URL[urls.size()]);
}
 
開發者ID:aliyun,項目名稱:aliyun-cupid-sdk,代碼行數:28,代碼來源:OdpsCltWrapper.java

示例8: parseProcess

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
public static ProcessDefinition parseProcess(byte[] bytes,long processId,boolean parseChildren) throws Exception{
	ByteArrayInputStream bin=new ByteArrayInputStream(bytes);
	try{
		SAXReader reader=new SAXReader();
		Document document=reader.read(bin);
		Element root=document.getRootElement();
		if(processParser.support(root)){
			ProcessDefinition pd=(ProcessDefinition)processParser.parse(root,processId,parseChildren);
			return pd;
		}
		return null;
	}finally{
		IOUtils.closeQuietly(bin);
	}
}
 
開發者ID:youseries,項目名稱:uflo,代碼行數:16,代碼來源:ProcessParser.java

示例9: run

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
public void run() {
    try {
        IOUtils.copy(input, output);
    } catch (IOException e) {
        logger.error("", e);
    } finally {
        IOUtils.closeQuietly(output);
    }
}
 
開發者ID:luoyaogui,項目名稱:otter-G,代碼行數:10,代碼來源:Exec.java

示例10: releaseBuffer

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
@Override
public synchronized void releaseBuffer(ByteBuffer buffer) {
  if (buffer == EMPTY_BUFFER) return;
  Object val = getExtendedReadBuffers().remove(buffer);
  if (val == null) {
    throw new IllegalArgumentException("tried to release a buffer " +
        "that was not created by this stream, " + buffer);
  }
  if (val instanceof ClientMmap) {
    IOUtils.closeQuietly((ClientMmap)val);
  } else if (val instanceof ByteBufferPool) {
    ((ByteBufferPool)val).putBuffer(buffer);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:15,代碼來源:DFSInputStream.java

示例11: doReadDerby

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
/**
 * Derby does not allow to read from the blob after the connection has been closed.
 * It also requires an outcome of commit/rollback.
 */
@SuppressWarnings("PMD.EmptyCatchBlock")
private InputStream doReadDerby(String id) {
    Handle h = dbi.open();
    try {
        h.getConnection().setAutoCommit(false);

        List<Map<String, Object>> res = h.select("SELECT data FROM icon_filestore WHERE id=?", id);

        Optional<Blob> blob = res.stream()
            .map(row -> row.get("data"))
            .map(Blob.class::cast)
            .findFirst();

        if (blob.isPresent()) {
            return new HandleCloserInputStream(h, blob.get().getBinaryStream());
        } else {
            h.commit();
            h.close();
            return null;
        }

    } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") Exception e) {
        // Do cleanup
        try {
            h.rollback();
        } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") Exception ex) {
            // ignore
        }
        IOUtils.closeQuietly(h);

        throw IconDataAccessException.launderThrowable(e);
    }
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:38,代碼來源:SqlIconFileStore.java

示例12: closeResourcePack

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
public void closeResourcePack()
{
    if (this.reResourcePack instanceof Closeable)
    {
        IOUtils.closeQuietly((Closeable)this.reResourcePack);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:8,代碼來源:ResourcePackRepository.java

示例13: remove

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
private void remove(AbstractMetaStore metaStore) {
  if (metaStore.getFederationType() == PRIMARY) {
    primaryDatabaseMapping = null;
    primaryDatabasesCache.invalidateAll();
  } else {
    for (String databaseName : ((FederatedMetaStore) metaStore).getMappedDatabases()) {
      mappingsByDatabaseName.remove(databaseName.toLowerCase());
    }
  }
  DatabaseMapping removed = mappingsByMetaStoreName.remove(metaStore.getName());
  IOUtils.closeQuietly(removed);
}
 
開發者ID:HotelsDotCom,項目名稱:waggle-dance,代碼行數:13,代碼來源:StaticDatabaseMappingService.java

示例14: extract

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
public String extract(WordprocessingMLPackage wmlPackage) throws Exception {
	StringBuilderWriter output = new StringBuilderWriter(); 
	try {
		this.extract(wmlPackage, output);
	} finally {
		IOUtils.closeQuietly(output);
	}
	return output.toString();
}
 
開發者ID:vindell,項目名稱:docx4j-template,代碼行數:10,代碼來源:WordprocessingMLPackageExtractor.java

示例15: size

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
@Override
public long size(String queueID) {
    Jedis jedis = jedisPool.getResource();
    try {
        return jedis.hlen(makeDataKey(queueID));
    } finally {
        IOUtils.closeQuietly(jedis);
    }
}
 
開發者ID:virjar,項目名稱:vscrawler,代碼行數:10,代碼來源:JedisQueueStore.java


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