001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.xbean.terminal.telnet;
018
019 import java.io.OutputStream;
020 import java.io.PrintStream;
021
022 public class TelnetPrintStream extends PrintStream {
023 private final byte[] CRLF = new byte[]{(byte) '\r', (byte) '\n'};
024
025 public TelnetPrintStream(OutputStream out) {
026 super(out);
027 }
028
029 public void println() {
030 newLine();
031 }
032
033 public void println(String x) {
034 synchronized (this) {
035 print(x);
036 newLine();
037 }
038 }
039
040 public void println(long x) {
041 synchronized (this) {
042 print(x);
043 newLine();
044 }
045 }
046
047 public void println(char x) {
048 synchronized (this) {
049 print(x);
050 newLine();
051 }
052 }
053
054 public void println(boolean x) {
055 synchronized (this) {
056 print(x);
057 newLine();
058 }
059 }
060
061 public void println(float x) {
062 synchronized (this) {
063 print(x);
064 newLine();
065 }
066 }
067
068 public void println(double x) {
069 synchronized (this) {
070 print(x);
071 newLine();
072 }
073 }
074
075 public void println(int x) {
076 synchronized (this) {
077 print(x);
078 newLine();
079 }
080 }
081
082 public void println(char x[]) {
083 synchronized (this) {
084 print(x);
085 newLine();
086 }
087 }
088
089 private void newLine() {
090 try {
091 this.write(CRLF);
092 } catch (Exception e) {
093 }
094 }
095 }