1 /* 2 * Copyright (C) 2009 The Guava Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 * in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the License 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 * or implied. See the License for the specific language governing permissions and limitations under 12 * the License. 13 */ 14 15 package com.google.common.io; 16 17 import com.google.common.annotations.GwtIncompatible; 18 import java.io.DataOutput; 19 import java.io.IOException; 20 21 /** 22 * An extension of {@code DataOutput} for writing to in-memory byte arrays; its methods offer 23 * identical functionality but do not throw {@link IOException}. 24 * 25 * @author Jayaprabhakar Kadarkarai 26 * @since 1.0 27 */ 28 @GwtIncompatible 29 public interface ByteArrayDataOutput extends DataOutput { 30 @Override 31 void write(int b); 32 33 @Override 34 void write(byte b[]); 35 36 @Override 37 void write(byte b[], int off, int len); 38 39 @Override 40 void writeBoolean(boolean v); 41 42 @Override 43 void writeByte(int v); 44 45 @Override 46 void writeShort(int v); 47 48 @Override 49 void writeChar(int v); 50 51 @Override 52 void writeInt(int v); 53 54 @Override 55 void writeLong(long v); 56 57 @Override 58 void writeFloat(float v); 59 60 @Override 61 void writeDouble(double v); 62 63 @Override 64 void writeChars(String s); 65 66 @Override 67 void writeUTF(String s); 68 69 /** 70 * @deprecated This method is dangerous as it discards the high byte of every character. For 71 * UTF-8, use {@code write(s.getBytes(StandardCharsets.UTF_8))}. 72 */ 73 @Deprecated 74 @Override 75 void writeBytes(String s); 76 77 /** 78 * Returns the contents that have been written to this instance, as a byte array. 79 */ 80 byte[] toByteArray(); 81 }