001/* 002 * Copyright (C) 2009 The Guava Authors 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 005 * in compliance with the License. You may obtain a copy of the License at 006 * 007 * http://www.apache.org/licenses/LICENSE-2.0 008 * 009 * Unless required by applicable law or agreed to in writing, software distributed under the License 010 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 011 * or implied. See the License for the specific language governing permissions and limitations under 012 * the License. 013 */ 014 015package com.google.common.io; 016 017import com.google.common.annotations.GwtIncompatible; 018import java.io.DataOutput; 019import java.io.IOException; 020 021/** 022 * An extension of {@code DataOutput} for writing to in-memory byte arrays; its methods offer 023 * identical functionality but do not throw {@link IOException}. 024 * 025 * @author Jayaprabhakar Kadarkarai 026 * @since 1.0 027 */ 028@GwtIncompatible 029@ElementTypesAreNonnullByDefault 030public interface ByteArrayDataOutput extends DataOutput { 031 @Override 032 void write(int b); 033 034 @Override 035 void write(byte b[]); 036 037 @Override 038 void write(byte b[], int off, int len); 039 040 @Override 041 void writeBoolean(boolean v); 042 043 @Override 044 void writeByte(int v); 045 046 @Override 047 void writeShort(int v); 048 049 @Override 050 void writeChar(int v); 051 052 @Override 053 void writeInt(int v); 054 055 @Override 056 void writeLong(long v); 057 058 @Override 059 void writeFloat(float v); 060 061 @Override 062 void writeDouble(double v); 063 064 @Override 065 void writeChars(String s); 066 067 @Override 068 void writeUTF(String s); 069 070 /** 071 * @deprecated This method is dangerous as it discards the high byte of every character. For 072 * UTF-8, use {@code write(s.getBytes(StandardCharsets.UTF_8))}. 073 */ 074 @Deprecated 075 @Override 076 void writeBytes(String s); 077 078 /** Returns the contents that have been written to this instance, as a byte array. */ 079 byte[] toByteArray(); 080}