Code example for Writer

Methods: write

0
    } 
 
    public static void writeEscapedChar(Writer writer, char c) throws IOException {
        if ((c >= ' ') && (c < 0x7f)) {
            if ((c == '\'') || (c == '\"') || (c == '\\')) {
                writer.write('\\');
            } 
            writer.write(c);
            return; 
        } else if (c <= 0x7f) {
            switch (c) {
                case '\n': writer.write("\\n"); return;
                case '\r': writer.write("\\r"); return;
                case '\t': writer.write("\\t"); return;
            } 
        } 
 
        writer.write("\\u");
        writer.write(Character.forDigit(c >> 12, 16));
        writer.write(Character.forDigit((c >> 8) & 0x0f, 16));
        writer.write(Character.forDigit((c >> 4) & 0x0f, 16));
        writer.write(Character.forDigit(c & 0x0f, 16));
 
    } 
 
    public static void writeEscapedString(Writer writer, String value) throws IOException {
        for (int i = 0; i < value.length(); i++) {