001: /***
002: * Retrotranslator: a Java bytecode transformer that translates Java classes
003: * compiled with JDK 5.0 into classes that can be run on JVM 1.4.
004: *
005: * Copyright (c) 2005 - 2008 Taras Puchko
006: * All rights reserved.
007: *
008: * Redistribution and use in source and binary forms, with or without
009: * modification, are permitted provided that the following conditions
010: * are met:
011: * 1. Redistributions of source code must retain the above copyright
012: * notice, this list of conditions and the following disclaimer.
013: * 2. Redistributions in binary form must reproduce the above copyright
014: * notice, this list of conditions and the following disclaimer in the
015: * documentation and/or other materials provided with the distribution.
016: * 3. Neither the name of the copyright holders nor the names of its
017: * contributors may be used to endorse or promote products derived from
018: * this software without specific prior written permission.
019: *
020: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
021: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
022: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
023: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
024: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
025: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
026: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
027: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
028: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
029: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
030: * THE POSSIBILITY OF SUCH DAMAGE.
031: */package net.sf.retrotranslator.runtime.java.io;
032:
033: import java.io.*;
034: import java.util.*;
035:
036: /**
037: * @author Taras Puchko
038: */
039: public class _PrintWriter {
040:
041: public static Writer convertConstructorArguments(File file)
042: throws FileNotFoundException {
043: return new BufferedWriter(new OutputStreamWriter(
044: new FileOutputStream(file)));
045: }
046:
047: public static Writer convertConstructorArguments(File file,
048: String csn) throws FileNotFoundException,
049: UnsupportedEncodingException {
050: return new BufferedWriter(new OutputStreamWriter(
051: new FileOutputStream(file), csn));
052: }
053:
054: public static Writer convertConstructorArguments(String fileName)
055: throws FileNotFoundException {
056: return new BufferedWriter(new OutputStreamWriter(
057: new FileOutputStream(fileName)));
058: }
059:
060: public static Writer convertConstructorArguments(String fileName,
061: String csn) throws FileNotFoundException,
062: UnsupportedEncodingException {
063: return new BufferedWriter(new OutputStreamWriter(
064: new FileOutputStream(fileName), csn));
065: }
066:
067: public static PrintWriter append(PrintWriter writer,
068: CharSequence csq) {
069: writer.write(String.valueOf(csq));
070: return writer;
071: }
072:
073: public static PrintWriter append(PrintWriter writer,
074: CharSequence csq, int start, int end) {
075: writer.write(String.valueOf(csq).substring(start, end));
076: return writer;
077: }
078:
079: public static PrintWriter append(PrintWriter writer, char c) {
080: writer.write(c);
081: return writer;
082: }
083:
084: public static PrintWriter format(PrintWriter printWriter,
085: Locale locale, String format, Object... args) {
086: new Formatter(printWriter, locale).format(format, args);
087: printWriter.flush();
088: return printWriter;
089: }
090:
091: public static PrintWriter format(PrintWriter printWriter,
092: String format, Object... args) {
093: new Formatter(printWriter).format(format, args);
094: printWriter.flush();
095: return printWriter;
096: }
097:
098: public static PrintWriter printf(PrintWriter printWriter,
099: Locale locale, String format, Object... args) {
100: return format(printWriter, locale, format, args);
101: }
102:
103: public static PrintWriter printf(PrintWriter printWriter,
104: String format, Object... args) {
105: return format(printWriter, format, args);
106: }
107:
108: }
|