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 com.google.common.annotations.J2ktIncompatible; 19 import java.io.DataOutput; 20 import java.io.IOException; 21 22 /** 23 * An extension of {@code DataOutput} for writing to in-memory byte arrays; its methods offer 24 * identical functionality but do not throw {@link IOException}. 25 * 26 * @author Jayaprabhakar Kadarkarai 27 * @since 1.0 28 */ 29 @J2ktIncompatible 30 @GwtIncompatible 31 @ElementTypesAreNonnullByDefault 32 public interface ByteArrayDataOutput extends DataOutput { 33 @Override write(int b)34 void write(int b); 35 36 @Override write(byte b[])37 void write(byte b[]); 38 39 @Override write(byte b[], int off, int len)40 void write(byte b[], int off, int len); 41 42 @Override writeBoolean(boolean v)43 void writeBoolean(boolean v); 44 45 @Override writeByte(int v)46 void writeByte(int v); 47 48 @Override writeShort(int v)49 void writeShort(int v); 50 51 @Override writeChar(int v)52 void writeChar(int v); 53 54 @Override writeInt(int v)55 void writeInt(int v); 56 57 @Override writeLong(long v)58 void writeLong(long v); 59 60 @Override writeFloat(float v)61 void writeFloat(float v); 62 63 @Override writeDouble(double v)64 void writeDouble(double v); 65 66 @Override writeChars(String s)67 void writeChars(String s); 68 69 @Override writeUTF(String s)70 void writeUTF(String s); 71 72 /** 73 * @deprecated This method is dangerous as it discards the high byte of every character. For 74 * UTF-8, use {@code write(s.getBytes(StandardCharsets.UTF_8))}. 75 */ 76 @Deprecated 77 @Override writeBytes(String s)78 void writeBytes(String s); 79 80 /** Returns the contents that have been written to this instance, as a byte array. */ toByteArray()81 byte[] toByteArray(); 82 } 83