2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package com
.sun
.star
.lib
.uno
.adapter
;
21 import java
.io
.IOException
;
23 import com
.sun
.star
.io
.XOutputStream
;
25 import java
.io
.OutputStream
;
28 * The <code>XOutputStreamToOutputStreamAdapter</code> wraps
29 * the UNO <code>XOutputStream</code> object in a Java
30 * <code>OutputStream</code>. This allows users to access
31 * an <code>XOutputStream</code> as if it were an
32 * <code>OutputStream</code>.
34 public final class XOutputStreamToOutputStreamAdapter
extends OutputStream
{
37 * Internal handle to the XInputStream
44 * @param out The <code>XOutputStream</code> to be
45 * accessed as an <code>OutputStream</code>.
47 public XOutputStreamToOutputStreamAdapter(XOutputStream out
) {
52 public void close() throws IOException
{
55 } catch (Exception e
) {
56 IOException newEx
= new IOException(e
.getMessage());
63 public void flush() throws IOException
{
66 } catch (Exception e
) {
67 IOException newEx
= new IOException(e
.getMessage());
74 public void write(byte[] b
) throws IOException
{
78 } catch (Exception e
) {
79 IOException newEx
= new IOException(e
.getMessage());
86 public void write(byte[] b
, int off
, int len
) throws IOException
{
88 byte[] tmp
= new byte[len
];
90 // Copy the input array into a temp array, and write it out.
92 System
.arraycopy(b
, off
, tmp
, 0, len
);
96 } catch (Exception e
) {
97 IOException newEx
= new IOException(e
.getMessage());
104 public void write(int b
) throws IOException
{
106 byte [] oneByte
= new byte [1];
107 oneByte
[0] = (byte) b
;
110 xout
.writeBytes(oneByte
);
111 } catch (Exception e
) {
112 IOException newEx
= new IOException(e
.getMessage());