1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package com.sun.star.lib.uno.adapter; 25 26 import java.io.IOException; 27 import com.sun.star.io.XOutputStream; 28 import java.io.OutputStream; 29 30 /** The <code>OutputStreamToXOutputStreamAdapter</code> wraps 31 a a UNO <code>XOutputStream</code> into a Java <code>OutputStream</code> 32 object in a Java. This allows users to access an <code>OutputStream</code> 33 as if it were an <code>XOutputStream</code>. 34 */ 35 public class OutputStreamToXOutputStreamAdapter implements XOutputStream { 36 37 /** 38 * Internal handle to the OutputStream 39 */ 40 OutputStream iOut; 41 42 /** 43 * Constructor. 44 * 45 * @param out The <code>XOutputStream</code> to be 46 * accessed as an <code>OutputStream</code>. 47 */ OutputStreamToXOutputStreamAdapter(OutputStream out)48 public OutputStreamToXOutputStreamAdapter(OutputStream out) { 49 iOut = out; 50 } 51 closeOutput()52 public void closeOutput() throws 53 com.sun.star.io.IOException 54 { 55 try { 56 iOut.close(); 57 } catch (IOException e) { 58 throw new com.sun.star.io.IOException(e.toString()); 59 } 60 } 61 flush()62 public void flush() throws 63 com.sun.star.io.IOException 64 { 65 try { 66 iOut.flush(); 67 } catch (IOException e) { 68 throw new com.sun.star.io.IOException(e.toString()); 69 } 70 } 71 writeBytes(byte[] b)72 public void writeBytes(byte[] b) throws 73 com.sun.star.io.IOException 74 { 75 76 try { 77 iOut.write(b); 78 } catch (IOException e) { 79 throw new com.sun.star.io.IOException(e.toString()); 80 } 81 } 82 83 } 84