Package com.jedics.util

Source Code of com.jedics.util.LogStream

package com.jedics.util;

import com.jedics.swing.ScrollableJTextArea;

import java.io.*;
import java.util.Locale;


public class LogStream extends PrintStream {
  private PrintStream out;
  private boolean writeOut;
  private ScrollableJTextArea text;
 
  public LogStream(String filename) throws IOException {
    super(filename);
    text = new ScrollableJTextArea();
    writeOut = true;
  }
 
  public LogStream() throws IOException {
    super(System.out);
    text = new ScrollableJTextArea();
    writeOut = true;
  }
 
  public void println() {
    append("\n");
    if(writeOut && out != null)
      out.println();
  }
  public void println(String x) {
    append(x + "\n");
    if(writeOut && out != null)
      out.println(x);
  }
  public void println(Object x) {
    if(x == null)
      append("null\n");
    append(x.toString() + "\n");
    if(writeOut && out != null)
      out.println(x);
  }
  public void println(boolean x) {
    append(x + "\n");
    if(writeOut && out != null)
      out.println(x);
  }
  public void println(char x) {
    append(x + "\n");
    if(writeOut && out != null)
      out.println(x);
  }
  public void println(byte x) {
    append(x + "\n");
    if(writeOut && out != null)
      out.println(x);
  }
  public void println(short x) {
    append(x + "\n");
    if(writeOut && out != null)
      out.println(x);
  }
  public void println(int x) {
    append(x + "\n");
    if(writeOut && out != null)
      out.println(x);
  }
  public void println(long x) {
    append(x + "\n");
    if(writeOut && out != null)
      out.println(x);
  }
  public void println(float x) {
    append(x + "\n");
    if(writeOut && out != null)
      out.println(x);
  }
  public void println(double x) {
    append(x + "\n");
    if(writeOut && out != null)
      out.println(x);
  }
 
  public void print(String x) {
    append(x);
    if(writeOut && out != null)
      out.print(x);
  }
  public void print(Object x) {
    if(x == null);
      append("null\n");
    append(x.toString());
    if(writeOut && out != null)
      out.print(x);
  }
  public void print(boolean x) {
    append(x + "");
    if(writeOut && out != null)
      out.print(x);
  }
  public void print(char x) {
    append(x + "");
    if(writeOut && out != null)
      out.print(x);
  }
  public void print(byte x) {
    append(x + "");
    if(writeOut && out != null)
      out.print(x);
  }
  public void print(short x) {
    append(x + "");
    if(writeOut && out != null)
      out.print(x);
  }
  public void print(int x) {
    append(x + "");
    if(writeOut && out != null)
      out.print(x);
  }
  public void print(long x) {
    append(x + "");
    if(writeOut && out != null)
      out.print(x);
  }
  public void print(float x) {
    append(x + "");
    if(writeOut && out != null)
      out.print(x);
  }
  public void print(double x) {
    append(x + "");
    if(writeOut && out != null)
      out.print(x);
  }
 
  public PrintStream printf(String format, Object ...data) {
    append(String.format(format, data));
    if(writeOut && out != null)
      out.printf(format, data);
    return this;
  }
 
  public PrintStream printf(Locale l, String format, Object ...data) {
    append(String.format(l, format, data));
    if(writeOut && out != null)
      out.printf(l, format, data);
    return this;
  }
 
  public void append(final String s) {
    text.append(s);
  }
 
  public ScrollableJTextArea getTextArea() {
    return text;
  }
 
 
  public boolean getWriteOut() {
    return writeOut;
  }
  public void setWriteOut(boolean b) {
    this.writeOut = b;
  }
}
TOP

Related Classes of com.jedics.util.LogStream

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.