当前位置: 首页>>代码示例>>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;未经允许,请勿转载。