本文整理汇总了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());
}
示例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 "";
}
}
}
示例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();
}
示例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);
}
示例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 "";
}
}
}
示例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;
}
}
}
示例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();
}
示例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> <small>(left
* brace)</small> and ending with <code>}</code> <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();
}
}
示例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> <small>(left
* bracket)</small> and ending with <code>]</code>
* <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();
}
}
示例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> <small>(left
* brace)</small> and ending with <code>}</code> <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();
}
}
示例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> <small>(left
* bracket)</small> and ending with <code>]</code>
* <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();
}
}
示例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> <small>(left
* bracket)</small> and ending with <code>]</code>
* <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();
}
}