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


Java StringWriter.getBuffer方法代碼示例

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


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

示例1: encode

import java.io.StringWriter; //導入方法依賴的package包/類
protected StringBuffer
encode(
	Map		map,
	boolean	simple )
{
	StringWriter	writer = new StringWriter(1024);

	setOutputWriter( writer );

	setGenericSimple( simple );

	writeGeneric( map );

	flushOutputStream();

	return( writer.getBuffer());
}
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:18,代碼來源:BEncoder.java

示例2: quote

import java.io.StringWriter; //導入方法依賴的package包/類
/**
 * Produce a string in double quotes with backslash sequences in all the
 * right places. A backslash will be inserted within </, producing <\/,
 * allowing JSON text to be delivered in HTML. In JSON text, a string cannot
 * contain a control character or an unescaped quote or backslash.
 *
 * @param string
 *            A String
 * @return A String correctly formatted for insertion in a JSON text.
 */
public static String quote(String string) {
    StringWriter sw = new StringWriter();
    synchronized (sw.getBuffer()) {
        try {
            return quote(string, sw).toString();
        } catch (IOException ignored) {
            // will never happen - we are writing to a string writer
            return "";
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:JSONObject.java

示例3: getTraceInfo

import java.io.StringWriter; //導入方法依賴的package包/類
public static String getTraceInfo(Throwable t) {
    StringWriter stringWriter = new StringWriter();
    PrintWriter writer = new PrintWriter(stringWriter);
    t.printStackTrace(writer);
    StringBuffer buffer = stringWriter.getBuffer();
    return buffer.toString();
}
 
開發者ID:Ulyssesss,項目名稱:one,代碼行數:8,代碼來源:ExceptionUtils.java

示例4: TwoColumnOutput

import java.io.StringWriter; //導入方法依賴的package包/類
/**
 * Constructs an instance.
 *
 * @param out {@code non-null;} writer to send final output to
 * @param leftWidth {@code > 0;} width of the left column, in characters
 * @param rightWidth {@code > 0;} width of the right column, in characters
 * @param spacer {@code non-null;} spacer string to sit between the two columns
 */
public TwoColumnOutput(Writer out, int leftWidth, int rightWidth,
                       String spacer) {
    if (out == null) {
        throw new NullPointerException("out == null");
    }

    if (leftWidth < 1) {
        throw new IllegalArgumentException("leftWidth < 1");
    }

    if (rightWidth < 1) {
        throw new IllegalArgumentException("rightWidth < 1");
    }

    if (spacer == null) {
        throw new NullPointerException("spacer == null");
    }

    StringWriter leftWriter = new StringWriter(1000);
    StringWriter rightWriter = new StringWriter(1000);

    this.out = out;
    this.leftWidth = leftWidth;
    this.leftBuf = leftWriter.getBuffer();
    this.rightBuf = rightWriter.getBuffer();
    this.leftColumn = new IndentingWriter(leftWriter, leftWidth);
    this.rightColumn =
        new IndentingWriter(rightWriter, rightWidth, spacer);
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:38,代碼來源:TwoColumnOutput.java

示例5: quote

import java.io.StringWriter; //導入方法依賴的package包/類
/**
 * Produce a string in double quotes with backslash sequences in all the
 * right places. A backslash will be inserted within </, producing <\/,
 * allowing JSON text to be delivered in HTML. In JSON text, a string cannot
 * contain a control character or an unescaped quote or backslash.
 *
 * @param string A String
 * @return A String correctly formatted for insertion in a JSON text.
 */
public static String quote(String string) {
    StringWriter sw = new StringWriter();
    synchronized (sw.getBuffer()) {
        try {
            return quote(string, sw).toString();
        } catch (IOException ignored) {
            // will never happen - we are writing to a string writer
            return "";
        }
    }
}
 
開發者ID:shawlaf,項目名稱:Banmanager,代碼行數:21,代碼來源:JSONObject.java

示例6: toString

import java.io.StringWriter; //導入方法依賴的package包/類
public String toString() {
  StringWriter w = new StringWriter();
  synchronized (w.getBuffer()) {
    try {
      return this.write(w).toString();
    } catch (Exception e) {
      return null;
    }
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:11,代碼來源:TypedJson.java

示例7: toString

import java.io.StringWriter; //導入方法依賴的package包/類
/**
 * Transform the properties to string format
 * @param properties the properties object
 * @return the string containing the properties
 * @throws IOException
 */
public static String toString(Properties properties) throws IOException {
  StringWriter writer = new StringWriter();
  properties.store(writer, null);
  StringBuffer stringBuffer = writer.getBuffer();
  filterPropertiesComment(stringBuffer);
  return stringBuffer.toString();
}
 
開發者ID:dewey-its,項目名稱:apollo-custom,代碼行數:14,代碼來源:PropertiesUtil.java

示例8: toString

import java.io.StringWriter; //導入方法依賴的package包/類
/**
 * Make a prettyprinted JSON text of this JSONObject.
 * <p>
 * Warning: This method assumes that the data structure is acyclical.
 *
 * @param indentFactor
 *            The number of spaces to add to each level of indentation.
 * @return a printable, displayable, portable, transmittable representation
 *         of the object, beginning with <code>{</code>&nbsp;<small>(left
 *         brace)</small> and ending with <code>}</code>&nbsp;<small>(right
 *         brace)</small>.
 * @throws JSONException
 *             If the object contains an invalid number.
 */
public String toString(int indentFactor) throws JSONException {
    StringWriter w = new StringWriter();
    synchronized (w.getBuffer()) {
        return this.write(w, indentFactor, 0).toString();
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:JSONObject.java

示例9: toString

import java.io.StringWriter; //導入方法依賴的package包/類
/**
 * Make a prettyprinted JSON text of this JSONArray. Warning: This method
 * assumes that the data structure is acyclical.
 *
 * @param indentFactor
 *            The number of spaces to add to each level of indentation.
 * @return a printable, displayable, transmittable representation of the
 *         object, beginning with <code>[</code>&nbsp;<small>(left
 *         bracket)</small> and ending with <code>]</code>
 *         &nbsp;<small>(right bracket)</small>.
 * @throws JSONException
 */
public String toString(int indentFactor) throws JSONException {
    StringWriter sw = new StringWriter();
    synchronized (sw.getBuffer()) {
        return this.write(sw, indentFactor, 0).toString();
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:JSONArray.java

示例10: toString

import java.io.StringWriter; //導入方法依賴的package包/類
/**
 * Make a pretty-printed JSON text of this JSONObject.
 * 
 * <p>If <code>indentFactor > 0</code> and the {@link JSONObject}
 * has only one key, then the object will be output on a single line:
 * <pre>{@code {"key": 1}}</pre>
 * 
 * <p>If an object has 2 or more keys, then it will be output across
 * multiple lines: <code><pre>{
 *  "key1": 1,
 *  "key2": "value 2",
 *  "key3": 3
 * }</pre></code>
 * <p><b>
 * Warning: This method assumes that the data structure is acyclical.
 * </b>
 *
 * @param indentFactor
 *            The number of spaces to add to each level of indentation.
 * @return a printable, displayable, portable, transmittable representation
 *         of the object, beginning with <code>{</code>&nbsp;<small>(left
 *         brace)</small> and ending with <code>}</code>&nbsp;<small>(right
 *         brace)</small>.
 * @throws JSONException
 *             If the object contains an invalid number.
 */
public String toString(int indentFactor) throws JSONException {
    StringWriter w = new StringWriter();
    synchronized (w.getBuffer()) {
        return this.write(w, indentFactor, 0).toString();
    }
}
 
開發者ID:Trumeet,項目名稱:FlarumSDK,代碼行數:33,代碼來源:JSONObject.java

示例11: toString

import java.io.StringWriter; //導入方法依賴的package包/類
/**
 * Make a prettyprinted JSON text of this JSONArray. Warning: This method
 * assumes that the data structure is acyclical.
 *
 * @param indentFactor
 *            The number of spaces to add to each level of
 *            indentation.
 * @return a printable, displayable, transmittable representation of the
 *         object, beginning with <code>[</code>&nbsp;<small>(left
 *         bracket)</small> and ending with <code>]</code> &nbsp;
 *         <small>(right bracket)</small>.
 * @throws JSONException
 *             If the data structure is not acyclical
 */
public String toString(int indentFactor) throws JSONException {
	StringWriter sw = new StringWriter();
	synchronized (sw.getBuffer()) {
		return this.write(sw, indentFactor, 0).toString();
	}
}
 
開發者ID:to2mbn,項目名稱:authlib-injector,代碼行數:21,代碼來源:JSONArray.java

示例12: toString

import java.io.StringWriter; //導入方法依賴的package包/類
/**
 * Make a prettyprinted JSON text of this JSONArray. Warning: This method
 * assumes that the data structure is acyclical.
 * 
 * @param indentFactor
 *            The number of spaces to add to each level of indentation.
 * @return a printable, displayable, transmittable representation of the
 *         object, beginning with <code>[</code>&nbsp;<small>(left
 *         bracket)</small> and ending with <code>]</code> &nbsp;
 *         <small>(right bracket)</small>.
 * @throws JSONException
 */
public String toString(int indentFactor) throws JSONException {
    StringWriter sw = new StringWriter();
    synchronized (sw.getBuffer()) {
        return this.write(sw, indentFactor, 0).toString();
    }
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:19,代碼來源:JSONArray.java


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