1 26 27 package it.stefanochizzolini.clown.bytes; 28 29 import java.io.EOFException ; 30 import java.io.IOException ; 31 32 35 public final class OutputStream 36 implements IOutputStream 37 { 38 private java.io.OutputStream stream; 42 44 public OutputStream( 46 java.io.OutputStream stream 47 ) 48 {this.stream = stream;} 49 51 public int write( 55 byte[] data 56 ) 57 { 58 try 59 {stream.write(data);} 60 catch(IOException e) 61 {throw new RuntimeException (e);} 62 63 return data.length; 64 } 65 66 public int write( 67 byte[] data, 68 int offset, 69 int length 70 ) 71 { 72 try 73 {stream.write(data,offset,length);} 74 catch(IOException e) 75 {throw new RuntimeException (e);} 76 77 return length; 78 } 79 80 public int write( 81 String data 82 ) 83 { 84 try 85 {stream.write(data.getBytes("ISO-8859-1"));} 86 catch(IOException e) 87 {throw new RuntimeException (e);} 88 89 return data.length(); 90 } 91 92 public int write( 93 IInputStream data 94 ) 95 { 96 try 97 { 98 byte[] baseData = new byte[(int)data.getLength()]; 100 data.seek(0); 102 data.read(baseData); 104 return write(baseData); 106 } 107 catch(EOFException e) 108 {throw new RuntimeException (e);} 109 } 110 } | Popular Tags |