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