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