1 /* 2 * ProGuard -- shrinking, optimization, obfuscation, and preverification 3 * of Java bytecode. 4 * 5 * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) 6 * 7 * This program is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License as published by the Free 9 * Software Foundation; either version 2 of the License, or (at your option) 10 * any later version. 11 * 12 * This program is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 15 * more details. 16 * 17 * You should have received a copy of the GNU General Public License along 18 * with this program; if not, write to the Free Software Foundation, Inc., 19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 */ 21 package proguard.classfile.io; 22 23 import java.io.*; 24 25 /** 26 * This class delegates its method calls to the corresponding DataOutput methods, 27 * converting its IOExceptions to RuntimeExceptions. 28 * 29 * @author Eric Lafortune 30 */ 31 final class RuntimeDataOutput 32 { 33 private final DataOutput dataOutput; 34 35 RuntimeDataOutput(DataOutput dataOutput)36 public RuntimeDataOutput(DataOutput dataOutput) 37 { 38 this.dataOutput = dataOutput; 39 } 40 41 42 // Methods delegating to DataOutput. 43 write(byte[] b)44 public void write(byte[] b) 45 { 46 try 47 { 48 dataOutput.write(b); 49 } 50 catch (IOException ex) 51 { 52 throw new RuntimeException(ex.getMessage()); 53 } 54 } 55 56 write(byte[] b, int off, int len)57 public void write(byte[] b, int off, int len) 58 { 59 try 60 { 61 dataOutput.write(b, off, len); 62 } 63 catch (IOException ex) 64 { 65 throw new RuntimeException(ex.getMessage()); 66 } 67 } 68 69 write(int b)70 public void write(int b) 71 { 72 try 73 { 74 dataOutput.write(b); 75 } 76 catch (IOException ex) 77 { 78 throw new RuntimeException(ex.getMessage()); 79 } 80 } 81 82 writeBoolean(boolean v)83 public void writeBoolean(boolean v) 84 { 85 try 86 { 87 dataOutput.writeBoolean(v); 88 } 89 catch (IOException ex) 90 { 91 throw new RuntimeException(ex.getMessage()); 92 } 93 } 94 95 writeByte(int v)96 public void writeByte(int v) 97 { 98 try 99 { 100 dataOutput.writeByte(v); 101 } 102 catch (IOException ex) 103 { 104 throw new RuntimeException(ex.getMessage()); 105 } 106 } 107 108 writeBytes(String s)109 public void writeBytes(String s) 110 { 111 try 112 { 113 dataOutput.writeBytes(s); 114 } 115 catch (IOException ex) 116 { 117 throw new RuntimeException(ex.getMessage()); 118 } 119 } 120 121 writeChar(int v)122 public void writeChar(int v) 123 { 124 try 125 { 126 dataOutput.writeChar(v); 127 } 128 catch (IOException ex) 129 { 130 throw new RuntimeException(ex.getMessage()); 131 } 132 } 133 134 writeChars(String s)135 public void writeChars(String s) 136 { 137 try 138 { 139 dataOutput.writeChars(s); 140 } 141 catch (IOException ex) 142 { 143 throw new RuntimeException(ex.getMessage()); 144 } 145 } 146 147 writeDouble(double v)148 public void writeDouble(double v) 149 { 150 try 151 { 152 dataOutput.writeDouble(v); 153 } 154 catch (IOException ex) 155 { 156 throw new RuntimeException(ex.getMessage()); 157 } 158 } 159 160 writeFloat(float v)161 public void writeFloat(float v) 162 { 163 try 164 { 165 dataOutput.writeFloat(v); 166 } 167 catch (IOException ex) 168 { 169 throw new RuntimeException(ex.getMessage()); 170 } 171 } 172 173 writeInt(int v)174 public void writeInt(int v) 175 { 176 try 177 { 178 dataOutput.writeInt(v); 179 } 180 catch (IOException ex) 181 { 182 throw new RuntimeException(ex.getMessage()); 183 } 184 } 185 186 writeLong(long v)187 public void writeLong(long v) 188 { 189 try 190 { 191 dataOutput.writeLong(v); 192 } 193 catch (IOException ex) 194 { 195 throw new RuntimeException(ex.getMessage()); 196 } 197 } 198 199 writeShort(int v)200 public void writeShort(int v) 201 { 202 try 203 { 204 dataOutput.writeShort(v); 205 } 206 catch (IOException ex) 207 { 208 throw new RuntimeException(ex.getMessage()); 209 } 210 } 211 212 writeUTF(String str)213 public void writeUTF(String str) 214 { 215 try 216 { 217 dataOutput.writeUTF(str); 218 } 219 catch (IOException ex) 220 { 221 throw new RuntimeException(ex.getMessage()); 222 } 223 } 224 } 225