java.io

Class DataInputStream

Implemented Interfaces:
Closeable, DataInput
Known Direct Subclasses:
ByteSequence

public class DataInputStream
extends FilterInputStream
implements DataInput

A data input stream lets an application read primitive Java data types from an underlying input stream in a machine-independent way. An application uses a data output stream to write data that can later be read by a data input stream.
Since:
JDK1.0
See Also:
DataOutputStream

Field Summary

Fields inherited from class java.io.FilterInputStream

in

Constructor Summary

DataInputStream(InputStream in)
Creates a DataInputStream that uses the specified underlying InputStream.

Method Summary

@Deprecated
String readLine()
Deprecated. This method does not properly convert bytes to characters.
int
read(b[] )
Reads some number of bytes from the contained input stream and stores them into the buffer array b.
int
read(b[] , int off, int len)
Reads up to len bytes of data from the contained input stream into an array of bytes.
boolean
readBoolean()
See the general contract of the readBoolean method of DataInput.
byte
readByte()
See the general contract of the readByte method of DataInput.
char
readChar()
See the general contract of the readChar method of DataInput.
double
readDouble()
See the general contract of the readDouble method of DataInput.
float
readFloat()
See the general contract of the readFloat method of DataInput.
void
readFully(b[] )
See the general contract of the readFully method of DataInput.
void
readFully(b[] , int off, int len)
See the general contract of the readFully method of DataInput.
int
readInt()
See the general contract of the readInt method of DataInput.
long
readLong()
See the general contract of the readLong method of DataInput.
short
readShort()
See the general contract of the readShort method of DataInput.
String
readUTF()
See the general contract of the readUTF method of DataInput.
static String
readUTF(DataInput in)
Reads from the stream in a representation of a Unicode character string encoded in modified UTF-8 format; this string of characters is then returned as a String.
int
readUnsignedByte()
See the general contract of the readUnsignedByte method of DataInput.
int
readUnsignedShort()
See the general contract of the readUnsignedShort method of DataInput.
int
skipBytes(int n)
See the general contract of the skipBytes method of DataInput.

Methods inherited from class java.io.FilterInputStream

available, close, mark, markSupported, read, read, read, reset, skip

Methods inherited from class java.io.InputStream

available, close, mark, markSupported, read, read, read, reset, skip

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

DataInputStream

public DataInputStream(InputStream in)
Creates a DataInputStream that uses the specified underlying InputStream.
Parameters:
in - the specified input stream
Usages and Demos :

View More Examples of DataInputStream(InputStream in)
   1:         if (args.length == 1){
   2:             return new DataInputStream((InputStream)args[0]);
   3:         } else {
   4:             undefined(args, context);
   5:             return null;

View Full Code Here
   1:         
   2:         DataInput din = new DataInputStream(Setup.class.getResourceAsStream("Setup.class"));
   3:         din.skipBytes(start);
   4:         din.readFully(payload);
   5:         

View Full Code Here
   1:         In=new BufferedReader(new InputStreamReader(
   2:             new DataInputStream(S.getInputStream())));
   3:         Out=new PrintWriter(S.getOutputStream());
   4:         if (getreply()/100!=2)
   5:             throw new IOException("Illegal reply.");

View Full Code Here
   1:         int result= -1;
   2:         DataInputStream input= new DataInputStream((in));
   3:         String line;
   4:         ...
   5:         char result= '?';
   6:         DataInputStream input= new DataInputStream(in);
   7:    
   8:     
   9:         String line;

View Full Code Here

Method Details

String readLine

public final @Deprecated String readLine()
            throws IOException

Deprecated. This method does not properly convert bytes to characters. As of JDK 1.1, the preferred way to read lines of text is via the BufferedReader.readLine() method. Programs that use the DataInputStream class to read lines can be converted to use the BufferedReader class by replacing code of the form:

DataInputStream d = new DataInputStream(in);
with:
BufferedReader d
= new BufferedReader(new InputStreamReader(in));

See the general contract of the readLine method of DataInput.

Bytes for this operation are read from the contained input stream.

Returns:
the next line of text from this input stream.
Throws:
IOException - if an I/O error occurs.

read

public final int read(b[] )
            throws IOException
Reads some number of bytes from the contained input stream and stores them into the buffer array b. The number of bytes actually read is returned as an integer. This method blocks until input data is available, end of file is detected, or an exception is thrown.

If b is null, a NullPointerException is thrown. If the length of b is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

The first byte read is stored into element b[0], the next one into b[1], and so on. The number of bytes read is, at most, equal to the length of b. Let k be the number of bytes actually read; these bytes will be stored in elements b[0] through b[k-1], leaving elements b[k] through b[b.length-1] unaffected.

If the first byte cannot be read for any reason other than end of file, then an IOException is thrown. In particular, an IOException is thrown if the input stream has been closed.

The read(b) method has the same effect as:

 read(b, 0, b.length) 
 
Overrides:
read in interface FilterInputStream
Parameters:
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws:
IOException - if an I/O error occurs.
See Also:
FilterInputStream.in, java.io.InputStream.read(byte[], int, int)
Usages and Demos :

View More Examples of read(b[] )
   1: import java.net.URL;
   2: import java.io.DataInputStream;
   3: 
   4:         ...
   5:         try {
   6:             DataInputStream dis = new DataInputStream(url.openStream());
   7:         ...
   8:             dis.read(b);
   9:         } catch (java.io.IOException e) {

View Full Code Here
   1:         DataOutputStream  fout = null;
   2:         DataInputStream fin = null;
   3: 
   4:         ...
   5:             fin =
   6:                 new DataInputStream(new FileInputStream("data.dat"));
   7:         }
   8:         ...
   9:         System.out.print("byte array: ");
  10:         fin.read(b);
  11:         for (int i=0;i < b.length;i++)

View Full Code Here
   1:     PRUDPPacketReplyError(
   2:         DataInputStream        is,
   3:         int                    trans_id )
   4:         ...
   5:         
   6:         is.read( data );
   7:         
   8:         message    = new String( data );
   9:     }

View Full Code Here
   1: 
   2: import java.io.DataInputStream;
   3: import java.io.DataOutputStream;
   4:         ...
   5:     NetworkAdminNATUDPReply(
   6:         DataInputStream        is,
   7:         int                    trans_id )
   8:         ...
   9:         
  10:         is.read( bytes );
  11:         

View Full Code Here
   1: 
   2: import java.io.DataInputStream;
   3: import java.io.DataOutputStream;
   4:         ...
   5:     VersionCheckClientUDPReply(
   6:         DataInputStream        is,
   7:         int                    trans_id )
   8:         ...
   9:         
  10:         is.read( bytes );
  11:         

View Full Code Here

read

public final int read(b[] ,
                      int off,
                      int len)
            throws IOException
Reads up to len bytes of data from the contained input stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read, possibly zero. The number of bytes actually read is returned as an integer.

This method blocks until input data is available, end of file is detected, or an exception is thrown.

If b is null, a NullPointerException is thrown.

If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.

If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

The first byte read is stored into element b[off], the next one into b[off+1], and so on. The number of bytes read is, at most, equal to len. Let k be the number of bytes actually read; these bytes will be stored in elements b[off] through b[off+k-1], leaving elements b[off+k] through b[off+len-1] unaffected.

In every case, elements b[0] through b[off] and elements b[off+len] through b[b.length-1] are unaffected.

If the first byte cannot be read for any reason other than end of file, then an IOException is thrown. In particular, an IOException is thrown if the input stream has been closed.

Overrides:
read in interface FilterInputStream
Parameters:
off - the start offset of the data.
len - the maximum number of bytes read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws:
IOException - if an I/O error occurs.
See Also:
FilterInputStream.in, java.io.InputStream.read(byte[], int, int)
Usages and Demos :

View More Examples of read(b[] ,int off,int len)
   1:     
   2:     DataArrayInputStream(DataInputStream file,byte buff[]) throws IOException {
   3:         ...
   4:     file.read(buff,0,buff.length);
   5:     source=new ByteArrayInputStream(buff);
   6:         ...
   7:     public final int readUnsignedShort() throws IOException {
   8:     source.read(buffor,0,2);
   9:     return ((buffor[0]<<8)|(buffor[1]&0xff));
  10:         ...
  11:     public final short readShort() throws IOException{
  12:     source.read(buffor,0,2);

View Full Code Here
   1: 
   2: import java.io.DataInputStream;
   3: 
   4:         ...
   5: 
   6:     public DataInputStream getDescriptor()
   7:     {
   8:         ...
   9: 
  10:         return ( DataInputStream ) FileSystem.getList().elementAt( num - 1 );
  11:     }
  12:         ...
  13:         {
  14:             input.read( buffer, 0, num_bytes );

View Full Code Here
   1: 
   2:         DataInputStream dataInputStream =
   3:         ...
   4:             new DataInputStream(byteStream);
   5: 
   6:         ...
   7:             int thisSegmentLength =
   8:                 dataInputStream.read(buffer, offset, segmentLength);

View Full Code Here
   1:     byte fileSignature[] = new byte [signature.length];
   2:     DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
   3:     in.mark(signature.length);
   4:         ...
   5:     in.read(fileSignature, 0, signature.length);
   6:     for (int i = 0; i < signature.length; i++)
   7:       if (signature[i] != fileSignature[i])
   8:         {

View Full Code Here
   1: import java.io.ByteArrayInputStream;
   2: import java.io.DataInputStream;
   3: import java.io.*;
   4:         ...
   5:         _inputStream = new ByteArrayInputStream(_byteArray);
   6:         _input = new DataInputStream(_inputStream);
   7: 
   8:         ...
   9:         _inputStream = new ByteArrayInputStream(_byteArray);
  10:         _input = new DataInputStream(_inputStream);
  11: 
  12:         ...
  13:     
  14:     _input.read(b, 0, length-1);

View Full Code Here

readBoolean

public final boolean readBoolean()
            throws IOException
See the general contract of the readBoolean method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readBoolean in interface DataInput
Returns:
the boolean value read.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readBoolean()
   1: 
   2:       DataInputStream dis =
   3:         ...
   4:         new DataInputStream(fis);
   5: 
   6:         ...
   7:       System.out.println(dis.readBoolean());
   8:       System.out.println(dis.readByte());

View Full Code Here
   1:         FileInputStream fin = new FileInputStream("a.txt");
   2:         DataInputStream sin = new DataInputStream (fin);
   3:         try
   4:         ...
   5:         {
   6:             System.out.println(sin.readBoolean());
   7:             System.out.println(sin.readByte());
   8:             System.out.println(sin.readChar());
   9:             System.out.println(sin.readDouble());

View Full Code Here
   1: 
   2:     public static Object inputObject(DataInputStream in) throws IOException {
   3:         int type = in.readInt();
   4:         ...
   5:         } else if (type == BooleanType) {
   6:             return Boolean.valueOf(in.readBoolean());
   7: 
   8:         ...
   9: 
  10:     private static String readString(DataInputStream in) throws IOException {
  11:         int length = in.readInt();

View Full Code Here
   1: 
   2:     public static boolean read_bool(DataInputStream is) throws IOException
   3:     {
   4:         ...
   5:     return is.readBoolean();
   6:     }
   7:         ...
   8: 
   9:     public static short read_short_int(DataInputStream is) throws IOException
  10:     {
  11:         ...
  12: 
  13:     public static int read_int(DataInputStream is) throws IOException

View Full Code Here
   1: 
   2:     protected boolean read_bool(DataInputStream is) throws IOException
   3:     {
   4:         ...
   5:     return is.readBoolean();
   6:     }
   7:         ...
   8: 
   9:     protected short read_short_int(DataInputStream is) throws IOException
  10:     {
  11:         ...
  12: 
  13:     protected int read_int(DataInputStream is) throws IOException

View Full Code Here

readByte

public final byte readByte()
            throws IOException
See the general contract of the readByte method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readByte in interface DataInput
Returns:
the next byte of this input stream as a signed 8-bit byte.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readByte()
   1:     try {
   2:       DataInputStream in = new DataInputStream(
   3:         new ByteArrayInputStream(
   4:         ...
   5:       while(true)
   6:         System.out.print((char)in.readByte());
   7:     } catch(EOFException e) {
   8:       System.err.println("End of stream");
   9:     }

View Full Code Here
   1:   throws IOException {
   2:     DataInputStream vstup = 
   3:         ...
   4:       new DataInputStream(
   5:        new BufferedInputStream(
   6:         ...
   7:     while(vstup.available() != 0)
   8:       System.out.print((char)vstup.readByte());
   9:   }

View Full Code Here
   1:       try {
   2:         DataInputStream in3 =
   3:         ...
   4:           new DataInputStream(
   5:             new StringBufferInputStream(s2));
   6:         ...
   7:         while(true)
   8:           System.out.print((char)in3.readByte());
   9:       } catch(EOFException e) {
  10:         ...
  11:         out2.close();
  12:         DataInputStream in5 =

View Full Code Here
   1: 
   2:     public static boolean read_bool(DataInputStream is) throws IOException
   3:     {
   4:         ...
   5: 
   6:     public static short read_short_int(DataInputStream is) throws IOException
   7:     {
   8:         ...
   9: 
  10:     public static int read_int(DataInputStream is) throws IOException
  11:     {
  12:         ...
  13:     for (int i=0; i<len; ++i)
  14:         b.append((char)is.readByte());

View Full Code Here
   1: 
   2:     protected boolean read_bool(DataInputStream is) throws IOException
   3:     {
   4:         ...
   5: 
   6:     protected short read_short_int(DataInputStream is) throws IOException
   7:     {
   8:         ...
   9: 
  10:     protected int read_int(DataInputStream is) throws IOException
  11:     {
  12:         ...
  13:     for (int i=0; i<len; ++i)
  14:         b.append((char)is.readByte());

View Full Code Here

readChar

public final char readChar()
            throws IOException
See the general contract of the readChar method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readChar in interface DataInput
Returns:
the next two bytes of this input stream as a Unicode character.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readChar()
   1: 
   2:       DataInputStream dis =
   3:         ...
   4:         new DataInputStream(fis);
   5: 
   6:         ...
   7:       System.out.println(dis.readByte());
   8:       System.out.println(dis.readChar());
   9:       System.out.println(dis.readDouble());

View Full Code Here
   1:       FileInputStream inFileStream = new FileInputStream(inFile);
   2:       DataInputStream inDataStream = new DataInputStream(inFileStream);
   3: 
   4:         ...
   5:       outputBox.printLine(inDataStream.readDouble());
   6:       outputBox.printLine(inDataStream.readChar());
   7:       outputBox.printLine(inDataStream.readBoolean());
   8: 
   9:       inDataStream.close();

View Full Code Here
   1:         FileInputStream fin = new FileInputStream("a.txt");
   2:         DataInputStream sin = new DataInputStream (fin);
   3:         try
   4:         ...
   5:             System.out.println(sin.readByte());
   6:             System.out.println(sin.readChar());
   7:             System.out.println(sin.readDouble());
   8:             System.out.println(sin.readFloat());
   9:             System.out.println(sin.readInt());

View Full Code Here
   1: 
   2:         DataInputStream in = new DataInputStream(new
   3:                  FileInputStream("invoice1.txt"));
   4:         ...
   5:         char lineSep = System.getProperty("line.separator").charAt(0);
   6:         while ((chr = in.readChar()) != lineSep)
   7:             desc.append(chr);
   8:                 System.out.println("You've ordered " +
   9:                     unit + " units of " +

View Full Code Here
   1: 
   2:         DataInputStream in = new DataInputStream(
   3: new     FileInputStream("content.txt"));
   4: 
   5:         double price;

View Full Code Here

readDouble

public final double readDouble()
            throws IOException
See the general contract of the readDouble method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readDouble in interface DataInput
Returns:
the next eight bytes of this input stream, interpreted as a double.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readDouble()
   1:     out.close();
   2:     DataInputStream in = new DataInputStream(
   3:                     new FileInputStream("test.bin"));
   4:         ...
   5:     for (int i = 0; i < count; i++){
   6:       System.out.println(in.readDouble());
   7:     }
   8:   }
   9: }

View Full Code Here
   1: 
   2:       DataInputStream dis =
   3:         ...
   4:         new DataInputStream(fis);
   5: 
   6:         ...
   7:       System.out.println(dis.readChar());
   8:       System.out.println(dis.readDouble());
   9:       System.out.println(dis.readFloat());

View Full Code Here
   1:     out.close();
   2:     DataInputStream in = new DataInputStream(
   3:       new BufferedInputStream(
   4:         ...
   5:         new FileInputStream("Data.txt")));
   6:     System.out.println(in.readDouble());
   7:     System.out.println(in.readUTF());
   8:         ...
   9:     System.out.println(in.readDouble());
  10:     System.out.println(in.readUTF());

View Full Code Here
   1: 
   2:     DataInputStream in =
   3:         ...
   4:       new DataInputStream(
   5:         new BufferedInputStream(
   6:         ...
   7:         new InputStreamReader(in));
   8:     System.out.println(in.readDouble());
   9:     System.out.println(inbr.readLine());
  10:         ...
  11:     System.out.println(inbr.readLine());
  12:     System.out.println(in.readDouble());

View Full Code Here
   1:         FileInputStream fin = new FileInputStream("a.txt");
   2:         DataInputStream sin = new DataInputStream (fin);
   3:         try
   4:         ...
   5:             System.out.println(sin.readChar());
   6:             System.out.println(sin.readDouble());
   7:             System.out.println(sin.readFloat());
   8:             System.out.println(sin.readInt());
   9:             System.out.println(sin.readLong());

View Full Code Here

readFloat

public final float readFloat()
            throws IOException
See the general contract of the readFloat method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readFloat in interface DataInput
Returns:
the next four bytes of this input stream, interpreted as a float.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readFloat()
   1: 
   2:       DataInputStream dis =
   3:         ...
   4:         new DataInputStream(fis);
   5: 
   6:         ...
   7:       System.out.println(dis.readDouble());
   8:       System.out.println(dis.readFloat());
   9:       System.out.println(dis.readInt());

View Full Code Here
   1: 
   2:   Object read(DataInputStream dis) throws DatabaseException
   3:   {
   4:     try
   5:     {

View Full Code Here
   1:         FileInputStream fin = new FileInputStream("a.txt");
   2:         DataInputStream sin = new DataInputStream (fin);
   3:         try
   4:         ...
   5:             System.out.println(sin.readDouble());
   6:             System.out.println(sin.readFloat());
   7:             System.out.println(sin.readInt());
   8:             System.out.println(sin.readLong());
   9:             System.out.println(sin.readShort());

View Full Code Here
   1:                 URL datafile=new URL(root.codebase, "data/"+filename); 
   2:                 DataInputStream    datain = new DataInputStream(new BufferedInputStream(datafile.openStream())); 
   3:                 mon=datain.readShort(); lat=datain.readShort(); lon=datain.readShort(); 
   4:         ...
   5:                 min=datain.readFloat(); max=datain.readFloat(); 
   6:                 
   7:                 tot=lon*lat; 
   8:                 range=(max-min); 

View Full Code Here
   1: 
   2: import java.io.DataInputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:     public void read(DataInputStream cpStream) throws IOException {
   7:         ...
   8:         setValue(new Float(cpStream.readFloat()));
   9:     }

View Full Code Here

readFully

public final void readFully(b[] )
            throws IOException
See the general contract of the readFully method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readFully in interface DataInput
Parameters:
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readFully(b[] )
   1: 
   2:     DataInputStream file;
   3: 
   4:         ...
   5:     {
   6:         file = new DataInputStream(new BufferedInputStream(new FileInputStream(f)));
   7:     }
   8:         ...
   9:     {
  10:         file = new DataInputStream(new BufferedInputStream((url.openConnection()).getInputStream()));
  11:     }
  12:         ...
  13:     {
  14:         file.readFully(b);

View Full Code Here
   1: 
   2:   public static YakHost read(DataInputStream _in) throws IOException
   3:   {
   4:         ...
   5:     byte[] aa=new byte[4];
   6:     _in.readFully(aa);
   7:     String host=YakLib.toIP(aa,0);
   8:     int    port=_in.readShort();
   9:     if(port<0) port+=65536;

View Full Code Here
   1: 
   2: import java.io.DataInputStream;
   3: import java.io.DataOutputStream;
   4:         ...
   5:     {
   6:         DataInputStream din = new DataInputStream(in);
   7: 
   8:         ...
   9:         byte[] asig = new byte[6];
  10:         din.readFully(asig);

View Full Code Here
   1: 
   2: import java.io.DataInputStream;
   3: import java.io.DataOutputStream;
   4:         ...
   5:     {
   6:         DataInputStream din = new DataInputStream(in);
   7: 
   8:         ...
   9:         byte[] asig = new byte[6];
  10:         din.readFully(asig);
  11: 
  12:         ...
  13:             byte[] aword = new byte[wordlen];
  14:             din.readFully(aword);

View Full Code Here
   1: package org.activemq.streams;
   2: import java.io.DataInputStream;
   3: import java.io.DataOutputStream;
   4:         ...
   5:     protected DataOutputStream out;
   6:     protected DataInputStream in;
   7: 
   8:         ...
   9:         out = new DataOutputStream(new JMSOutputStream(producer));
  10:         in = new DataInputStream(new JMSInputStream(consumer));
  11:     }
  12:         ...
  13:                         byte[] b = new byte[2048];
  14:                         in.readFully(b);

View Full Code Here

readFully

public final void readFully(b[] ,
                            int off,
                            int len)
            throws IOException
See the general contract of the readFully method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readFully in interface DataInput
Parameters:
off - the start offset of the data.
len - the number of bytes to read.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readFully(b[] ,int off,int len)
   1: 
   2:     SSrvTypeMsg(SrvLocHeader hdr, DataInputStream dis)
   3:     throws ServiceLocationException, IOException {
   4:         ...
   5: 
   6:     void initialize(DataInputStream dis)
   7:     throws ServiceLocationException, IOException {
   8:         ...
   9:     parseNamingAuthorityIn(SrvLocHeader hdr,
  10:                    DataInputStream dis,
  11:                    String charCode)
  12:         ...
  13: 
  14:     dis.readFully(bStr, 0, len);

View Full Code Here
   1: import java.io.DataOutputStream;
   2: import java.io.DataInputStream;
   3: import java.io.BufferedInputStream;
   4:         ...
   5: 
   6:         DataInputStream in = new DataInputStream(sock.getInputStream());
   7:         int len = in.readInt();
   8:         ...
   9: 
  10:         in.readFully(buffer, 0, len);

View Full Code Here
   1:             System.out.println("-- accepted connection from " + client_sock.getRemoteSocketAddress());
   2:             DataInputStream in=new DataInputStream(new BufferedInputStream(client_sock.getInputStream()));
   3:             byte[] buf=new byte[size];
   4:         ...
   5:             while(counter < num) {
   6:                 in.readFully(buf, 0, buf.length);
   7:                 if(start == 0)
   8:                     start=System.currentTimeMillis();
   9:                 counter++;

View Full Code Here
   1: import java.io.BufferedInputStream;
   2: import java.io.DataInputStream;
   3: import java.io.DataOutputStream;
   4:         ...
   5:               try {
   6:                 DataInputStream in = new DataInputStream(sock.getInputStream());
   7:                 int len = in.readInt();
   8:         ...
   9: 
  10:                 in.readFully(buffer, 0, len);
  11:                 

View Full Code Here
   1: 
   2:         DataInputStream dis = null;
   3:         try {
   4:         ...
   5:             GZIPInputStream gzis = new GZIPInputStream(lexiconfi);
   6:             dis = new DataInputStream(gzis);
   7: 
   8:         ...
   9:                 byte[] buf = new byte[wordlen+1];
  10:                 dis.readFully(buf, 0, wordlen);
  11:                 word = new String(buf, 0, wordlen);

View Full Code Here

readInt

public final int readInt()
            throws IOException
See the general contract of the readInt method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readInt in interface DataInput
Returns:
the next four bytes of this input stream, interpreted as an int.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readInt()
   1: 
   2:   Object read(DataInputStream dis) throws DatabaseException
   3:   {
   4:     try
   5:     {

View Full Code Here
   1: 
   2:   public Field parse(DataInputStream dis) throws ParseException {
   3:     try {
   4:         ...
   5:         case INT_ID:
   6:           return new IntField(new Integer(dis.readInt()));
   7:         default:
   8:           return null;
   9:       }

View Full Code Here
   1: 
   2: import java.io.DataInputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:     public void read(DataInputStream input) throws IOException, CoreException {
   7:         int formatVersion = readVersionNumber(input);
   8:         ...
   9: 
  10:     protected static int readVersionNumber(DataInputStream input) throws IOException {
  11:         ...
  12:         return input.readInt();

View Full Code Here
   1: 
   2:     public Object unpickle (DataInputStream in) 
   3:     throws IOException
   4:         ...
   5:     {
   6:     return new Integer(in.readInt()) ;
   7:     }
   8:      
   9:     public IntegerAttribute(String name, Integer def, int flags) {

View Full Code Here
   1: 
   2: import java.io.DataInputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:     public void readSyncInfo(DataInputStream input) throws IOException {
   7:         int formatVersion = readVersionNumber(input);
   8:         ...
   9: 
  10:     protected static int readVersionNumber(DataInputStream input) throws IOException {
  11:         ...
  12:         return input.readInt();

View Full Code Here

readLong

public final long readLong()
            throws IOException
See the general contract of the readLong method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readLong in interface DataInput
Returns:
the next eight bytes of this input stream, interpreted as a long.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readLong()
   1: 
   2:       DataInputStream dis =
   3:         ...
   4:         new DataInputStream(fis);
   5: 
   6:         ...
   7:       System.out.println(dis.readInt());
   8:       System.out.println(dis.readLong());
   9:       System.out.println(dis.readShort());

View Full Code Here
   1:         FileInputStream fin = new FileInputStream("a.txt");
   2:         DataInputStream sin = new DataInputStream (fin);
   3:         try
   4:         ...
   5:             System.out.println(sin.readInt());
   6:             System.out.println(sin.readLong());
   7:             System.out.println(sin.readShort());
   8:         }
   9:         finally

View Full Code Here
   1: 
   2:     public Object unpickle (DataInputStream in) 
   3:     throws IOException
   4:         ...
   5:     {
   6:     return new Long(in.readLong()) ;
   7:     }
   8:      
   9:     public LongAttribute(String name, Long def, int flags) {

View Full Code Here
   1:         DataOutputStream  fout = null;
   2:         DataInputStream fin = null;
   3: 
   4:         ...
   5:             fin =
   6:                 new DataInputStream(new FileInputStream("data.dat"));
   7:         }
   8:         ...
   9:         System.out.println("short:  " + fin.readShort());
  10:         System.out.println("long:   " + fin.readLong());

View Full Code Here
   1:     try {
   2:       DataInputStream data = new DataInputStream(
   3:         new ByteArrayInputStream(classBytes));
   4:       int minorVersion = data.readShort();
   5:       int majorVersion = data.readShort();

View Full Code Here

readShort

public final short readShort()
            throws IOException
See the general contract of the readShort method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readShort in interface DataInput
Returns:
the next two bytes of this input stream, interpreted as a signed 16-bit number.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readShort()
   1: 
   2:       DataInputStream dis =
   3:         ...
   4:         new DataInputStream(fis);
   5: 
   6:         ...
   7:       for(int i = 0; i < 15; i++) {
   8:         System.out.print(dis.readShort() + " ");
   9:       }

View Full Code Here
   1:     try {
   2:       DataInputStream data = new DataInputStream(
   3:         new ByteArrayInputStream(classBytes));
   4:         ...
   5:       int minorVersion = data.readShort();
   6:         ...
   7:       int majorVersion = data.readShort();
   8:         ...
   9:       int constant_pool_count = data.readShort();

View Full Code Here
   1: 
   2:     public static boolean read_bool(DataInputStream is) throws IOException
   3:     {
   4:         ...
   5: 
   6:     public static short read_short_int(DataInputStream is) throws IOException
   7:     {
   8:         ...
   9:     return is.readShort();
  10:     }
  11:         ...
  12: 
  13:     public static int read_int(DataInputStream is) throws IOException

View Full Code Here
   1: 
   2:     protected boolean read_bool(DataInputStream is) throws IOException
   3:     {
   4:         ...
   5: 
   6:     protected short read_short_int(DataInputStream is) throws IOException
   7:     {
   8:         ...
   9:     return is.readShort();
  10:     }
  11:         ...
  12: 
  13:     protected int read_int(DataInputStream is) throws IOException

View Full Code Here
   1: 
   2: import java.io.DataInputStream;
   3: import java.io.IOException;
   4:         ...
   5: public class EndianDataInputStream {
   6:     private java.io.DataInputStream inputStream;
   7: 
   8:         ...
   9:     public short readShortBE() throws IOException {
  10:         return inputStream.readShort();
  11:     }

View Full Code Here

readUTF

public final String readUTF()
            throws IOException
See the general contract of the readUTF method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readUTF in interface DataInput
Returns:
a Unicode string.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readUTF()
   1:     out.close();
   2:     DataInputStream in = new DataInputStream(
   3:       new BufferedInputStream(
   4:         ...
   5:     System.out.println(in.readDouble());
   6:     System.out.println(in.readUTF());
   7:     System.out.println(in.readDouble());
   8:         ...
   9:     System.out.println(in.readUTF());
  10:   }

View Full Code Here
   1: 
   2:     public void readFrom(DataInputStream in) throws IOException, IllegalAccessException, InstantiationException {
   3:         ...
   4:         group_addr=in.readUTF();
   5:     }
   6: 
   7:     public long size() {

View Full Code Here
   1:     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   2:         channel_name=in.readUTF();
   3:     }
   4:         ...
   5: 
   6:     public void readFrom(DataInputStream in) throws IOException, IllegalAccessException, InstantiationException {
   7:         ...
   8:         channel_name=in.readUTF();
   9:         if(channel_name != null)

View Full Code Here
   1: 
   2: import java.io.DataInputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:     public Command readCommand(DataInputStream in) throws IOException {
   7:         ...
   8:         String text = in.readUTF();
   9:         return readCommand(text);

View Full Code Here
   1:     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   2:         channel_name=in.readUTF();
   3:     }
   4:         ...
   5: 
   6:     public void readFrom(DataInputStream in) throws IOException, IllegalAccessException, InstantiationException {
   7:         ...
   8:         channel_name=in.readUTF();
   9:         if(channel_name != null)

View Full Code Here

readUTF

public static final String readUTF(DataInput in)
            throws IOException
Reads from the stream in a representation of a Unicode character string encoded in modified UTF-8 format; this string of characters is then returned as a String. The details of the modified UTF-8 representation are exactly the same as for the readUTF method of DataInput.
Parameters:
in - a data input stream.
Returns:
a Unicode string.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readUTF(DataInput in)
   1: import java.io.DataInput;
   2: import java.io.DataInputStream;
   3: import java.io.IOException;
   4:         ...
   5:       this.in = in;
   6:       this.d = new DataInputStream(in);
   7:       w = new byte[8];
   8:         ...
   9: 
  10:    public final static String readUTF(DataInput in) throws IOException {return DataInputStream.readUTF(in);}

View Full Code Here
   1: import java.io.ByteArrayOutputStream;
   2: import java.io.DataInputStream;
   3: import java.io.DataOutputStream;
   4:         ...
   5:     {
   6:         return DataInputStream.readUTF(this);
   7:     }
   8: 
   9:     public void write(byte[] b, int off, int len) throws IOException

View Full Code Here
   1:     public String readUTF() throws IOException {
   2:         return DataInputStream.readUTF(this);
   3:     }
   4: 
   5:     public float readFloat() throws IOException {

View Full Code Here
   1:     public final String readUTF() throws IOException {
   2:         return DataInputStream.readUTF(this);
   3:     }
   4:         ...
   5:     public final String readLine() throws IOException {
   6:         return DataInputStream.readUTF(this);
   7:     }
   8: 

View Full Code Here
   1: 
   2: import java.io.DataInputStream;
   3: import java.io.DataInput;
   4:         ...
   5:     public String readUTF() throws IOException {
   6:         return DataInputStream.readUTF(this);
   7:     }
   8:     
   9:     public int getStartOffset() {

View Full Code Here

readUnsignedByte

public final int readUnsignedByte()
            throws IOException
See the general contract of the readUnsignedByte method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readUnsignedByte in interface DataInput
Returns:
the next byte of this input stream, interpreted as an unsigned 8-bit number.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readUnsignedByte()
   1:     FileInputStream inputFileReader = new FileInputStream(argv[0]);
   2:     DataInputStream dis = new DataInputStream(inputFileReader);
   3:     long fileSize;
   4:         ...
   5:       try {
   6:         myVector.addElement(new Integer(dis.readUnsignedByte()));
   7:       } catch (EOFException e) {
   8:         break;
   9:       }

View Full Code Here
   1: import java.io.DataInput;
   2: import java.io.DataInputStream;
   3: import java.io.IOException;
   4:         ...
   5:       this.in = in;
   6:       this.d = new DataInputStream(in);
   7:       w = new byte[8];
   8:         ...
   9:    public int read() throws IOException {   return in.read(); }
  10:    public final int readUnsignedByte() throws IOException {return d.readUnsignedByte();}
  11: 
  12:         ...
  13: 
  14:    public final static String readUTF(DataInput in) throws IOException {return DataInputStream.readUTF(in);}

View Full Code Here
   1: 
   2: import java.io.DataInputStream;
   3: import java.io.IOException;
   4:         ...
   5: public class EndianDataInputStream {
   6:     private java.io.DataInputStream inputStream;
   7: 
   8:         ...
   9:     public int readUnsignedByteBE() throws IOException {
  10:         return inputStream.readUnsignedByte();
  11:     }

View Full Code Here
   1: import java.io.ByteArrayInputStream;
   2: import java.io.DataInputStream;
   3: import java.io.IOException;
   4:         ...
   5:             ByteArrayInputStream bais = new ByteArrayInputStream(proxiesBytes);
   6:             DataInputStream in = new DataInputStream(bais);
   7:             
   8:         ...
   9:             while(in.available() > 0) {
  10:                 int length = in.readUnsignedByte();
  11:                 

View Full Code Here
   1:     
   2:     PresContextImpl(int type, DataInputStream din, int len)
   3:             throws IOException, PDUException {
   4:         ...
   5:         this.type = type;
   6:         this.pcid = din.readUnsignedByte();
   7:         ...
   8:         din.readUnsignedByte();
   9:         ...
  10:         this.result = din.readUnsignedByte();

View Full Code Here

readUnsignedShort

public final int readUnsignedShort()
            throws IOException
See the general contract of the readUnsignedShort method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readUnsignedShort in interface DataInput
Returns:
the next two bytes of this input stream, interpreted as an unsigned 16-bit integer.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readUnsignedShort()
   1: 
   2: import java.io.DataInputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:     public void parse(DataInputStream dis) throws IOException {
   7:     }
   8: }

View Full Code Here
   1: 
   2: import java.io.DataInputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:     public void parse(DataInputStream dis) throws IOException {
   7:         ...
   8:         int length = dis.readUnsignedShort();
   9:         byte[] contents = new byte[length];

View Full Code Here
   1: import java.io.ByteArrayInputStream;
   2: import java.io.DataInputStream;
   3: import java.io.IOException;
   4:         ...
   5:     {
   6:       DataInputStream dis = new DataInputStream(
   7:         new ByteArrayInputStream(buffer, offset, buffer.length));
   8:         ...
   9: 
  10:       int length = dis.readUnsignedShort();

View Full Code Here
   1: 
   2:     public void parse(DataInputStream dis) throws IOException {
   3: 
   4:         ...
   5:         JConstantPool constant_pool =
   6:                 new JConstantPool(dis.readUnsignedShort());
   7:         constant_pool.parse(dis);
   8:         ...
   9: 
  10:         access_flags = dis.readUnsignedShort();
  11:         ...
  12:         int this_class_index = dis.readUnsignedShort();

View Full Code Here
   1: 
   2: import java.io.DataInputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:    protected DataInputStream inputStream;
   7: 
   8:         ...
   9: 
  10:    public AMFDeserializer(DataInputStream inputStream) throws IOException
  11:    {
  12:         ...
  13:    {
  14:       inputStream.readUnsignedShort();

View Full Code Here

skipBytes

public final int skipBytes(int n)
            throws IOException
See the general contract of the skipBytes method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
skipBytes in interface DataInput
Parameters:
n - the number of bytes to be skipped.
Returns:
the actual number of bytes skipped.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of skipBytes(int n)
   1: 
   2: import java.io.DataInputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:     public void read(ConstantPool constantPool, DataInputStream dis) throws IOException {
   7:         access_flags = dis.readShort();
   8:         ...
   9:             } else {
  10:                 dis.skipBytes(len);
  11:             }
  12:         ...
  13: 
  14:     protected void readCode(ConstantPool constantPool, DataInputStream dis) throws IOException {

View Full Code Here
   1: 
   2: import java.io.DataInputStream;
   3: import java.io.IOException;
   4:         ...
   5:     public ClassFile(InputStream is) throws IOException {
   6:         DataInputStream dis = new DataInputStream(is);
   7:         ConstantPool constantPool = new ConstantPool();
   8:         ...
   9:                 int len = dis.readInt();
  10:                 dis.skipBytes(len);
  11:             }
  12:         ...
  13:             } else {
  14:                 dis.skipBytes(len);

View Full Code Here
   1: 
   2: import java.io.DataInputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:     protected MD2Model(DataInputStream input) throws IOException {
   7:         
   8:         ...
   9:         
  10:         input.skipBytes(64);
  11:         
  12:         ...
  13:         
  14:     public long readUnsignedInt(DataInputStream input) throws IOException {

View Full Code Here
   1: 
   2: import java.io.DataInputStream;
   3: import java.io.IOException;
   4:         ...
   5:     Connection connection;
   6:     DataInputStream in;
   7:     OutputStream out;
   8:         ...
   9:                 if ((encoding & Protocol.EncodingTimestamp) != 0) {
  10:                     in.skipBytes(4);
  11:                     size -= 4;

View Full Code Here
   1: import java.awt.Color;
   2: import java.io.DataInputStream;
   3: import java.io.IOException;
   4:         ...
   5: public class Connection extends ProtocolPreferences {
   6:     DataInputStream in;
   7:     OutputStream out;
   8:         ...
   9:         blueShift = in.readUnsignedByte();
  10:         in.skipBytes(3);
  11:         int nameLength = in.readInt();

View Full Code Here