⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stringprintwriter.java

📁 java 写的一个新闻发布系统
💻 JAVA
字号:
////                                   ____.//                       __/\ ______|    |__/\.     _______//            __   .____|    |       \   |    +----+       \//    _______|  /--|    |    |    -   \  _    |    :    -   \_________//   \\______: :---|    :    :           |    :    |         \________>//           |__\---\_____________:______:    :____|____:_____\//                                      /_____|////                 . . . i n   j a h i a   w e   t r u s t . . .//package org.jahia.services.applications;import java.io.*;import java.text.*;import java.util.*;import javax.servlet.*;import javax.servlet.http.*;import org.jahia.utils.JahiaConsole;/** * A simple PrintWriter based class that writes to a String rather than a OutputStream or such... * * Personal note : this isn't the most fascinating code I've ever written, but it is a sort of * emulator we are writing here so... :) * * Note : none of this is supposed to be optimised in anyway, it was done a quick and dirty way * using mostly already available functions calls to make this reliable. * * CHECKME : should be complete, bugs may subsist in some conversion, see CHECKMEs below * * @author : Serge Huber * */public class StringPrintWriter extends PrintWriter {    private StringBuffer strBuffer = new StringBuffer(4096);    private static boolean debugPrintWriter = false;    public StringPrintWriter(java.io.OutputStream out) {        super(out);    }    public StringPrintWriter(Writer out) {        super(out);    }    public StringPrintWriter(java.io.OutputStream out, boolean autoFlush) {        super(out, autoFlush);    }    public StringPrintWriter(Writer writer, boolean autoFlush) {        super(writer, autoFlush);    }    public StringPrintWriter(Writer writer, StringBuffer newBuffer) {        super(writer);        strBuffer = newBuffer;    }    public void print(boolean b) {        strBuffer.append(b);    }    public void print(char c) {        // debugLog("StringPrintWriter.print", "char");        strBuffer.append(c);    }    public void print(char[] s) {        // debugLog("StringPrintWriter.print", "char[]");        strBuffer.append(s);    }    public void print(double d) {        strBuffer.append(d);    }    public void print(float f) {        strBuffer.append(f);    }    public void print(int i) {        strBuffer.append(i);    }    public void print(long l) {        strBuffer.append(l);    }    public void print(Object obj) {        strBuffer.append(obj);    }    public void print(String s) {        // debugLog("StringPrintWriter.print", "String");        strBuffer.append(s);    }    public void println() {        // debugLog("StringPrintWriter.println", "(no arg)");        strBuffer.append("\n");    }    public void println(boolean b) {        strBuffer.append(b);        strBuffer.append("\n");    }    public void println(char c) {        // debugLog("StringPrintWriter.println", "char");        strBuffer.append(c);        strBuffer.append("\n");    }    public void println(char[] s) {        // debugLog("StringPrintWriter.println", "char[]");        strBuffer.append(s);        strBuffer.append("\n");    }    public void println(double d) {        strBuffer.append(d);        strBuffer.append("\n");    }    public void println(float f) {        strBuffer.append(f);        strBuffer.append("\n");    }    public void println(int i) {        strBuffer.append(i);        strBuffer.append("\n");    }    public void println(long l) {        strBuffer.append(l);        strBuffer.append("\n");    }    public void println(Object obj) {        strBuffer.append(obj);        strBuffer.append("\n");    }    public void println(String x) {        // debugLog("StringPrintWriter.println", "String");        strBuffer.append(x);        strBuffer.append("\n");    }    public void write(char[] cbuf) {        // debugLog("StringPrintWriter.write", "char[]");        strBuffer.append(cbuf);    }    public void write(char[] cbuf, int off, int len) {        // debugLog("StringPrintWriter.write", "char[], offset+length");        strBuffer.append(cbuf, off, len);    }    public void write(int c) {        // CHECKME : why is this an int and not a char ??        // debugLog("StringPrintWriter.write", "int");        strBuffer.append((char)c);    }    public void write(String s) {        // debugLog("StringPrintWriter.write", "String[" + s + "]");        strBuffer.append(s);    }    public void write(String str, int off, int len) {        // debugLog("StringPrintWriter.write", "String, offset+length");        strBuffer.append(str.substring(off, off+len)); // CHECKME : are the indexes correct here ?    }    public String getBuffer() {        return strBuffer.toString();    }    public void flush() {    }    public void close() {    }    public boolean checkError() {        // debugLog("StringPrinterWriter.checkError()", "called.");        return false;    }    private static void debugLog(String source, String message) {        if (debugPrintWriter) {            JahiaConsole.println(source, message);        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -