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


Java TemporaryBuffer.Heap方法代碼示例

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


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

示例1: replyJson

import org.eclipse.jgit.util.TemporaryBuffer; //導入方法依賴的package包/類
public static long replyJson(
    @Nullable HttpServletRequest req,
    HttpServletResponse res,
    ListMultimap<String, String> config,
    Object result)
    throws IOException {
  TemporaryBuffer.Heap buf = heap(HEAP_EST_SIZE, Integer.MAX_VALUE);
  buf.write(JSON_MAGIC);
  Writer w = new BufferedWriter(new OutputStreamWriter(buf, UTF_8));
  Gson gson = newGson(config, req);
  if (result instanceof JsonElement) {
    gson.toJson((JsonElement) result, w);
  } else {
    gson.toJson(result, w);
  }
  w.write('\n');
  w.flush();
  return replyBinaryResult(
      req, res, asBinaryResult(buf).setContentType(JSON_TYPE).setCharacterEncoding(UTF_8));
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:21,代碼來源:RestApiServlet.java

示例2: stackJsonString

import org.eclipse.jgit.util.TemporaryBuffer; //導入方法依賴的package包/類
private static BinaryResult stackJsonString(HttpServletResponse res, BinaryResult src)
    throws IOException {
  TemporaryBuffer.Heap buf = heap(HEAP_EST_SIZE, Integer.MAX_VALUE);
  buf.write(JSON_MAGIC);
  try (Writer w = new BufferedWriter(new OutputStreamWriter(buf, UTF_8));
      JsonWriter json = new JsonWriter(w)) {
    json.setLenient(true);
    json.setHtmlSafe(true);
    json.value(src.asString());
    w.write('\n');
  }
  res.setHeader("X-FYI-Content-Encoding", "json");
  res.setHeader("X-FYI-Content-Type", src.getContentType());
  return asBinaryResult(buf).setContentType(JSON_TYPE).setCharacterEncoding(UTF_8);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:16,代碼來源:RestApiServlet.java

示例3: base64

import org.eclipse.jgit.util.TemporaryBuffer; //導入方法依賴的package包/類
private static BinaryResult base64(BinaryResult bin) throws IOException {
  int maxSize = base64MaxSize(bin.getContentLength());
  int estSize = Math.min(base64MaxSize(HEAP_EST_SIZE), maxSize);
  TemporaryBuffer.Heap buf = heap(estSize, maxSize);
  try (OutputStream encoded =
      BaseEncoding.base64().encodingStream(new OutputStreamWriter(buf, ISO_8859_1))) {
    bin.writeTo(encoded);
  }
  return asBinaryResult(buf);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:11,代碼來源:RestApiServlet.java

示例4: compress

import org.eclipse.jgit.util.TemporaryBuffer; //導入方法依賴的package包/類
private static BinaryResult compress(BinaryResult bin) throws IOException {
  TemporaryBuffer.Heap buf = heap(HEAP_EST_SIZE, 20 << 20);
  try (GZIPOutputStream gz = new GZIPOutputStream(buf)) {
    bin.writeTo(gz);
  }
  return asBinaryResult(buf).setContentType(bin.getContentType());
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:8,代碼來源:RestApiServlet.java

示例5: asBinaryResult

import org.eclipse.jgit.util.TemporaryBuffer; //導入方法依賴的package包/類
@SuppressWarnings("resource")
private static BinaryResult asBinaryResult(TemporaryBuffer.Heap buf) {
  return new BinaryResult() {
    @Override
    public void writeTo(OutputStream os) throws IOException {
      buf.writeTo(os, null);
    }
  }.setContentLength(buf.length());
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:10,代碼來源:RestApiServlet.java

示例6: readPegdownCss

import org.eclipse.jgit.util.TemporaryBuffer; //導入方法依賴的package包/類
private static String readPegdownCss(AtomicBoolean file) throws IOException {
  String name = "pegdown.css";
  URL url = MarkdownFormatter.class.getResource(name);
  if (url == null) {
    throw new FileNotFoundException("Resource " + name);
  }
  file.set("file".equals(url.getProtocol()));
  try (InputStream in = url.openStream();
      TemporaryBuffer.Heap tmp = new TemporaryBuffer.Heap(128 * 1024)) {
    tmp.copy(in);
    return new String(tmp.toByteArray(), UTF_8);
  }
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:14,代碼來源:MarkdownFormatter.java

示例7: heap

import org.eclipse.jgit.util.TemporaryBuffer; //導入方法依賴的package包/類
private static Heap heap(int est, int max) {
  return new TemporaryBuffer.Heap(est, max);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:4,代碼來源:RestApiServlet.java


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