org.apache.wicket.request.Response.getOutputStream()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(97)

本文整理了Java中org.apache.wicket.request.Response.getOutputStream方法的一些代码示例,展示了Response.getOutputStream的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.getOutputStream方法的具体详情如下:
包路径:org.apache.wicket.request.Response
类名称:Response
方法名:getOutputStream

Response.getOutputStream介绍

[英]Returns an OutputStream suitable for writing binary data in the response. The servlet container does not encode the binary data.

Calling flush() on the OutputStream commits the response.

This method returns an output stream that delegates to #write(byte[]), #write(byte[],int,int), and #close() methods of this response instance
[中]返回适合在响应中写入二进制数据的OutputStream。servlet容器不会对二进制数据进行编码。
在OutputStream上调用flush()提交响应。
此方法返回一个输出流,该流委托给此响应实例的#write(字节[])、#write(字节[]、int、int)和#close()方法

代码示例

代码示例来源:origin: theonedev/onedev

@Override
  public void writeData(Attributes attributes) throws IOException {
    String content = Joiner.on("\n").join(readServerLog());
    attributes.getResponse().getOutputStream().write(content.getBytes(Charsets.UTF_8));
  }                
});

代码示例来源:origin: theonedev/onedev

@Override
public void writeData(Attributes attributes) throws IOException {
  try (InputStream is = new FileInputStream(attachmentFile);) {
    IOUtils.copy(is, attributes.getResponse().getOutputStream());
  }
}

代码示例来源:origin: org.apache.wicket/wicket-core

@Override
  public void writeData(Attributes attributes) throws IOException
  {
    ((IResourceStreamWriter)resourceStream).write(attributes.getResponse().getOutputStream());
    close(resourceStream);
  }
});

代码示例来源:origin: apache/wicket

/**
   * Convenience method to write an {@link InputStream} to response.
   * 
   * @param attributes
   *            request attributes
   * @param stream
   *            input stream
   */
  protected final void writeStream(Attributes attributes, InputStream stream) throws IOException
  {
    final Response response = attributes.getResponse();
    Streams.copy(stream, response.getOutputStream());
  }
}

代码示例来源:origin: org.apache.wicket/wicket-core

/**
   * Convenience method to write an {@link InputStream} to response.
   * 
   * @param attributes
   *            request attributes
   * @param stream
   *            input stream
   */
  protected final void writeStream(Attributes attributes, InputStream stream) throws IOException
  {
    final Response response = attributes.getResponse();
    Streams.copy(stream, response.getOutputStream());
  }
}

代码示例来源:origin: apache/wicket

@Override
  public void writeData(Attributes attributes) throws IOException
  {
    ((IResourceStreamWriter)resourceStream).write(attributes.getResponse().getOutputStream());
    close(resourceStream);
  }
});

代码示例来源:origin: org.jabylon/rest.ui

@Override
  public void writeData(Attributes attributes) throws IOException {
    OutputStream outputStream = attributes.getResponse().getOutputStream();
    new XliffDownloadHelper(projectVersion, languageMap, filter, outputStream).handleXliffDownload();
  }
});

代码示例来源:origin: OrienteerBAP/Orienteer

@Override
  public void writeData(Attributes attributes) throws IOException {
    OutputStream out = attributes.getResponse().getOutputStream();
    GZIPOutputStream gzipOut = new GZIPOutputStream(out);
    ODatabaseDocumentInternal db = (ODatabaseDocumentInternal)OrientDbWebSession.get().getDatabase();
    ODatabaseExport dbExport = new ODatabaseExport(db, gzipOut, LoggerOCommandOutputListener.INSTANCE);
    configureODatabaseExport(dbExport);
    dbExport.exportDatabase();
  }
});

代码示例来源:origin: micromata/projectforge

private void jFreeChartExport()
{
 try {
  final ExportJFreeChart exportJFreeChart = (ExportJFreeChart) groovyResult.getResult();
  final StringBuilder sb = new StringBuilder();
  sb.append("pf_chart_");
  sb.append(DateHelper.getTimestampAsFilenameSuffix(new Date()));
  final Response response = getResponse();
  final String extension = exportJFreeChart.write(response.getOutputStream());
  sb.append('.').append(extension);
  final String filename = sb.toString();
  final int width = exportJFreeChart.getWidth();
  final int height = exportJFreeChart.getHeight();
  final JFreeChartImage image = new JFreeChartImage("image", exportJFreeChart.getJFreeChart(),
    exportJFreeChart.getImageType(), width,
    height);
  image.add(AttributeModifier.replace("width", String.valueOf(width)));
  image.add(AttributeModifier.replace("height", String.valueOf(height)));
  imageResultContainer.removeAll();
  imageResultContainer.add(image).setVisible(true);
  ((WebResponse) response).setAttachmentHeader(filename);
  ((WebResponse) response).setContentType(DownloadUtils.getContentType(filename));
  log.info("Starting download for file. filename:" + filename + ", content-type:"
    + DownloadUtils.getContentType(filename));
  response.getOutputStream().flush();
 } catch (final Exception ex) {
  error(getLocalizedMessage("error", ex.getMessage()));
  log.error(ex.getMessage(), ex);
 }
}

代码示例来源:origin: org.apache.wicket/wicket-core

@Override
  public void writeData(final Attributes attributes) throws IOException
  {
    try
    {
      InputStream inputStream = webExternalResourceStream.getInputStream();
      try
      {
        Streams.copy(inputStream, attributes.getResponse().getOutputStream());
      }
      finally {
        IOUtils.closeQuietly(inputStream);
      }
    }
    catch (ResourceStreamNotFoundException rsnfx)
    {
      throw new WicketRuntimeException(rsnfx);
    }
  }
});

代码示例来源:origin: apache/wicket

@Override
  public void writeData(final Attributes attributes) throws IOException
  {
    try
    {
      InputStream inputStream = webExternalResourceStream.getInputStream();
      try
      {
        Streams.copy(inputStream, attributes.getResponse().getOutputStream());
      }
      finally {
        IOUtils.closeQuietly(inputStream);
      }
    }
    catch (ResourceStreamNotFoundException rsnfx)
    {
      throw new WicketRuntimeException(rsnfx);
    }
  }
});

代码示例来源:origin: OrienteerBAP/Orienteer

@Override
 public void writeData(Attributes attributes) throws  IOException
 {
   IReportDocument cache;
  try {
    cache = reportData.getReportCache();
    IRenderTask renderTask = reportData.getReportEngine().createRenderTask(cache);
    
    OutputStream outputStream = attributes.getResponse().getOutputStream();
    renderTask.setRenderOption(getRenderOptions(outputStream));
    //run the report
    renderTask.render();
    cache.close();            
  } catch (EngineException e) {
    LOG.error("BIRT report generation failed", e);
  }
 }
});

代码示例来源:origin: org.apache.wicket/wicket-core

OutputStream outputStream = attributes.getResponse().getOutputStream();
byte[] buffer = new byte[getBufferSize()];

代码示例来源:origin: apache/wicket

OutputStream outputStream = attributes.getResponse().getOutputStream();
byte[] buffer = new byte[getBufferSize()];

代码示例来源:origin: theonedev/onedev

@Override
public void writeData(Attributes attributes) throws IOException {
  try (InputStream is = getInputStream(blob)) {
    Long startByte = RequestCycle.get().getMetaData(CONTENT_RANGE_STARTBYTE);
    Long endByte = RequestCycle.get().getMetaData(CONTENT_RANGE_ENDBYTE);
    if (startByte == null)
      startByte = 0L;
    if (endByte == null || endByte == -1)
      endByte = blob.getSize() - 1;
    copyRange(is, attributes.getResponse().getOutputStream(), startByte, endByte);
  }
}

代码示例来源:origin: theonedev/onedev

@Override
  public void writeData(Attributes attributes) throws IOException {
    if (format.equals("zip"))
      ArchiveCommand.registerFormat(format, new ZipFormat());
    else
      ArchiveCommand.registerFormat(format, new TgzFormat());
    try {
      ArchiveCommand archive = Git.wrap(project.getRepository()).archive();
      archive.setFormat(format);
      archive.setTree(project.getRevCommit(revision).getId());
      archive.setOutputStream(attributes.getResponse().getOutputStream());
      archive.call();
    } catch (GitAPIException e) {
      throw new RuntimeException(e);
    } finally {
      ArchiveCommand.unregisterFormat(format);
    }
  }                
});

相关文章