blob: f16de01a4f10fbd404b28b2d90a135294a740fba [file] [log] [blame]
Felix Meschbergerefb2d082008-08-19 13:18:47 +00001/*
2* Licensed to the Apache Software Foundation (ASF) under one or more
3* contributor license agreements. See the NOTICE file distributed with
4* this work for additional information regarding copyright ownership.
5* The ASF licenses this file to You under the Apache License, Version 2.0
6* (the "License"); you may not use this file except in compliance with
7* the License. You may obtain a copy of the License at
8*
9* http://www.apache.org/licenses/LICENSE-2.0
10*
11* Unless required by applicable law or agreed to in writing, software
12* distributed under the License is distributed on an "AS IS" BASIS,
13* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14* See the License for the specific language governing permissions and
15* limitations under the License.
16*/
17package org.apache.felix.shell.remote;
18
19
20import java.io.IOException;
21import java.io.OutputStream;
22import java.io.PrintStream;
23
24
25/**
26 * Class implementing a <tt>TerminalPrintStream</tt>.
Felix Meschbergerefb2d082008-08-19 13:18:47 +000027 */
28class TerminalPrintStream extends PrintStream
29{
30
31 /**
32 * Constructs a new instance wrapping the given <tt>OutputStream</tt>.
33 *
34 * @param tout the <tt>OutputStream</tt> to be wrapped.
35 */
36 public TerminalPrintStream( OutputStream tout )
37 {
38 super( tout );
39 }//constructor
40
41
42 public void print( String str )
43 {
44 try
45 {
46 byte[] bytes = str.getBytes();
47 out.write( bytes, 0, bytes.length );
48 flush();
49 }
50 catch ( IOException ex )
51 {
52 Activator.getServices().error( "TerminalPrintStream::print()", ex );
53 }
54 }//print
55
56
57 public void println( String str )
58 {
59 print( str + "\r\n" );
60 }//println
61
62
63 public void flush()
64 {
65 try
66 {
67 out.flush();
68 }
69 catch ( IOException ex )
70 {
71 Activator.getServices().error( "TerminalPrintStream::println()", ex );
72 }
73 }//flush
74
75}//class TerminalPrintStream