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


Java AttachmentInputStream.close方法代码示例

本文整理汇总了Java中org.ektorp.AttachmentInputStream.close方法的典型用法代码示例。如果您正苦于以下问题:Java AttachmentInputStream.close方法的具体用法?Java AttachmentInputStream.close怎么用?Java AttachmentInputStream.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.ektorp.AttachmentInputStream的用法示例。


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

示例1: updateSchema

import org.ektorp.AttachmentInputStream; //导入方法依赖的package包/类
@Override
public void updateSchema(JsonNode oldSchema, JsonNode newSchema) {
    // store new version of the schema as newest revision of the document
    db.update(newSchema);
    
    // prepare old schema as stream
    byte[] bytes = jsonNodeToBytes(oldSchema);
    InputStream stream = new ByteArrayInputStream(bytes);
    String oldRev = oldSchema.get("_rev").textValue();
    
    // create attachment as stream 
    // id will be revision of old schema
    // data will be stored as application/json content type
    // note that this also increment revision of the document
    AttachmentInputStream data = new AttachmentInputStream(oldRev, stream, "application/json");
    String id = newSchema.get("_id").textValue();
    db.createAttachment(id, getCurrentRevision(id), data);  
    
    try {
        data.close();
    } catch (IOException ex) {
        logger.error(ex);
    }
}
 
开发者ID:martin-kanis,项目名称:relax-dms,代码行数:25,代码来源:CouchDbRepositoryImpl.java

示例2: getDocumentByIdAndRev

import org.ektorp.AttachmentInputStream; //导入方法依赖的package包/类
@Override
public JsonNode getDocumentByIdAndRev(String id, String rev) {
    String currentRev = getCurrentRevision(id);
    JsonNode schema = null;
    
    // current and needed revisions are the same so return current version of the schema
    if (currentRev.equals(rev)) {
        return this.find(id);
    } else {
        AttachmentInputStream ais = db.getAttachment(id, rev);
        try {
            byte[] data = IOUtils.toByteArray(ais);
            ObjectReader reader = (new ObjectMapper()).reader();
            schema = reader.readTree(new ByteArrayInputStream(data));
            ais.close();
        } catch (IOException ex) {
            logger.error(ex);
        }
        return schema;
    }
}
 
开发者ID:martin-kanis,项目名称:relax-dms,代码行数:22,代码来源:CouchDbRepositoryImpl.java

示例3: doGet

import org.ektorp.AttachmentInputStream; //导入方法依赖的package包/类
protected void doGet(HttpServletRequest request,
		HttpServletResponse response) throws ServletException, IOException {

	String id = request.getParameter("id");
	if (id == null)
		return;
	if (id.equals(""))
		return;

	String contentType = "image/png";
	AttachmentInputStream data = DatabaseUtilities.getSingleton().getDB()
			.getAttachment(id, id);
	response.setContentType(contentType);
	response.setContentLength(longToInt(data.getContentLength()));
	OutputStream out = response.getOutputStream();
	byte[] buffer = new byte[1024];
	int count = 0;
	while ((count = data.read(buffer)) >= 0) {
		out.write(buffer, 0, count);
	}
	out.close();
	data.close();
}
 
开发者ID:IBM-Cloud,项目名称:drone-selfie,代码行数:24,代码来源:PictureServlet.java


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