Java Doc for DataInputStream.java in  » 6.0-JDK-Core » io-nio » java » io » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » io nio » java.io 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.io.InputStream
      java.io.FilterInputStream
         java.io.DataInputStream

DataInputStream
public class DataInputStream extends FilterInputStream implements DataInput(Code)
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.

DataInputStream is not necessarily safe for multithreaded access. Thread safety is optional and is the responsibility of users of methods in this class.
author:
   Arthur van Hoff
version:
   1.83, 05/05/07
See Also:   java.io.DataOutputStream
since:
   JDK1.0




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

Method Summary
final public  intread(byte b)
     Reads some number of bytes from the contained input stream and stores them into the buffer array b.
final public  intread(byte b, int off, int len)
     Reads up to len bytes of data from the contained input stream into an array of bytes.
final public  booleanreadBoolean()
     See the general contract of the readBoolean method of DataInput.
final public  bytereadByte()
     See the general contract of the readByte method of DataInput.
final public  charreadChar()
     See the general contract of the readChar method of DataInput.
final public  doublereadDouble()
     See the general contract of the readDouble method of DataInput.
final public  floatreadFloat()
     See the general contract of the readFloat method of DataInput.
final public  voidreadFully(byte b)
     See the general contract of the readFully method of DataInput.
final public  voidreadFully(byte b, int off, int len)
     See the general contract of the readFully method of DataInput.
final public  intreadInt()
     See the general contract of the readInt method of DataInput.
final public  StringreadLine()
     See the general contract of the readLine method of DataInput.
final public  longreadLong()
     See the general contract of the readLong method of DataInput.
final public  shortreadShort()
     See the general contract of the readShort method of DataInput.
final public  StringreadUTF()
     See the general contract of the readUTF method of DataInput.
final public static  StringreadUTF(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. 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.
final public  intreadUnsignedByte()
     See the general contract of the readUnsignedByte method of DataInput.
final public  intreadUnsignedShort()
     See the general contract of the readUnsignedShort method of DataInput.
final public  intskipBytes(int n)
     See the general contract of the skipBytes method of DataInput.

Bytes for this operation are read from the contained input stream.
Parameters:
  n - the number of bytes to be skipped.



Constructor Detail
DataInputStream
public DataInputStream(InputStream in)(Code)
Creates a DataInputStream that uses the specified underlying InputStream.
Parameters:
  in - the specified input stream




Method Detail
read
final public int read(byte b) throws IOException(Code)
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.

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

 read(b, 0, b.length) 
 

Parameters:
  b - the buffer into which the data is read. the total number of bytes read into the buffer, or-1 if there is no more data because the endof the stream has been reached.
exception:
  IOException - if the first byte cannot be read for any reasonother than end of file, the stream has been closed and the underlyinginput stream does not support reading after close, or another I/Oerror occurs.
See Also:   java.io.FilterInputStream.in
See Also:   java.io.InputStream.read(byte[]intint)



read
final public int read(byte b, int off, int len) throws IOException(Code)
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 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.
Parameters:
  b - the buffer into which the data is read.
Parameters:
  off - the start offset in the destination array b
Parameters:
  len - the maximum number of bytes read. the total number of bytes read into the buffer, or-1 if there is no more data because the endof the stream has been reached.
exception:
  NullPointerException - If b is null.
exception:
  IndexOutOfBoundsException - If off is negative, len is negative, or len is greater than b.length - off
exception:
  IOException - if the first byte cannot be read for any reasonother than end of file, the stream has been closed and the underlyinginput stream does not support reading after close, or another I/Oerror occurs.
See Also:   java.io.FilterInputStream.in
See Also:   java.io.InputStream.read(byte[]intint)




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

Bytes for this operation are read from the contained input stream. the boolean value read.
exception:
  EOFException - if this input stream has reached the end.
exception:
  IOException - the stream has been closed and the containedinput stream does not support reading after close, oranother I/O error occurs.
See Also:   java.io.FilterInputStream.in




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

Bytes for this operation are read from the contained input stream. the next byte of this input stream as a signed 8-bitbyte.
exception:
  EOFException - if this input stream has reached the end.
exception:
  IOException - the stream has been closed and the containedinput stream does not support reading after close, oranother I/O error occurs.
See Also:   java.io.FilterInputStream.in




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

Bytes for this operation are read from the contained input stream. the next two bytes of this input stream, interpreted as achar.
exception:
  EOFException - if this input stream reaches the end beforereading two bytes.
exception:
  IOException - the stream has been closed and the containedinput stream does not support reading after close, oranother I/O error occurs.
See Also:   java.io.FilterInputStream.in




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

Bytes for this operation are read from the contained input stream. the next eight bytes of this input stream, interpreted as adouble.
exception:
  EOFException - if this input stream reaches the end beforereading eight bytes.
exception:
  IOException - the stream has been closed and the containedinput stream does not support reading after close, oranother I/O error occurs.
See Also:   java.io.DataInputStream.readLong
See Also:   java.lang.Double.longBitsToDouble(long)




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

Bytes for this operation are read from the contained input stream. the next four bytes of this input stream, interpreted as afloat.
exception:
  EOFException - if this input stream reaches the end beforereading four bytes.
exception:
  IOException - the stream has been closed and the containedinput stream does not support reading after close, oranother I/O error occurs.
See Also:   java.io.DataInputStream.readInt
See Also:   java.lang.Float.intBitsToFloat(int)




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

Bytes for this operation are read from the contained input stream.
Parameters:
  b - the buffer into which the data is read.
exception:
  EOFException - if this input stream reaches the end beforereading all the bytes.
exception:
  IOException - the stream has been closed and the containedinput stream does not support reading after close, oranother I/O error occurs.
See Also:   java.io.FilterInputStream.in




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

Bytes for this operation are read from the contained input stream.
Parameters:
  b - the buffer into which the data is read.
Parameters:
  off - the start offset of the data.
Parameters:
  len - the number of bytes to read.
exception:
  EOFException - if this input stream reaches the end beforereading all the bytes.
exception:
  IOException - the stream has been closed and the containedinput stream does not support reading after close, oranother I/O error occurs.
See Also:   java.io.FilterInputStream.in




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

Bytes for this operation are read from the contained input stream. the next four bytes of this input stream, interpreted as anint.
exception:
  EOFException - if this input stream reaches the end beforereading four bytes.
exception:
  IOException - the stream has been closed and the containedinput stream does not support reading after close, oranother I/O error occurs.
See Also:   java.io.FilterInputStream.in




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

Bytes for this operation are read from the contained input stream. the next line of text from this input stream.
exception:
  IOException - if an I/O error occurs.
See Also:   java.io.BufferedReader.readLine
See Also:   java.io.FilterInputStream.in




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

Bytes for this operation are read from the contained input stream. the next eight bytes of this input stream, interpreted as along.
exception:
  EOFException - if this input stream reaches the end beforereading eight bytes.
exception:
  IOException - the stream has been closed and the containedinput stream does not support reading after close, oranother I/O error occurs.
See Also:   java.io.FilterInputStream.in




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

Bytes for this operation are read from the contained input stream. the next two bytes of this input stream, interpreted as asigned 16-bit number.
exception:
  EOFException - if this input stream reaches the end beforereading two bytes.
exception:
  IOException - the stream has been closed and the containedinput stream does not support reading after close, oranother I/O error occurs.
See Also:   java.io.FilterInputStream.in




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

Bytes for this operation are read from the contained input stream. a Unicode string.
exception:
  EOFException - if this input stream reaches the end beforereading all the bytes.
exception:
  IOException - the stream has been closed and the containedinput stream does not support reading after close, oranother I/O error occurs.
exception:
  UTFDataFormatException - if the bytes do not represent a validmodified UTF-8 encoding of a string.
See Also:   java.io.DataInputStream.readUTF(java.io.DataInput)




readUTF
final public static String readUTF(DataInput in) throws IOException(Code)
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. a Unicode string.
exception:
  EOFException - if the input stream reaches the endbefore all the bytes.
exception:
  IOException - the stream has been closed and the containedinput stream does not support reading after close, oranother I/O error occurs.
exception:
  UTFDataFormatException - if the bytes do not represent avalid modified UTF-8 encoding of a Unicode string.
See Also:   java.io.DataInputStream.readUnsignedShort



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

Bytes for this operation are read from the contained input stream. the next byte of this input stream, interpreted as anunsigned 8-bit number.
exception:
  EOFException - if this input stream has reached the end.
exception:
  IOException - the stream has been closed and the containedinput stream does not support reading after close, oranother I/O error occurs.
See Also:   java.io.FilterInputStream.in




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

Bytes for this operation are read from the contained input stream. the next two bytes of this input stream, interpreted as anunsigned 16-bit integer.
exception:
  EOFException - if this input stream reaches the end beforereading two bytes.
exception:
  IOException - the stream has been closed and the containedinput stream does not support reading after close, oranother I/O error occurs.
See Also:   java.io.FilterInputStream.in




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

Bytes for this operation are read from the contained input stream.
Parameters:
  n - the number of bytes to be skipped. the actual number of bytes skipped.
exception:
  IOException - if the contained input stream does not supportseek, or the stream has been closed andthe contained input stream does not support reading after close, or another I/O error occurs.




Fields inherited from java.io.FilterInputStream
protected volatile InputStream in(Code)(Java Doc)

Methods inherited from java.io.FilterInputStream
public int available() throws IOException(Code)(Java Doc)
public void close() throws IOException(Code)(Java Doc)
public synchronized void mark(int readlimit)(Code)(Java Doc)
public boolean markSupported()(Code)(Java Doc)
public int read() throws IOException(Code)(Java Doc)
public int read(byte b) throws IOException(Code)(Java Doc)
public int read(byte b, int off, int len) throws IOException(Code)(Java Doc)
public synchronized void reset() throws IOException(Code)(Java Doc)
public long skip(long n) throws IOException(Code)(Java Doc)

Methods inherited from java.io.InputStream
public int available() throws IOException(Code)(Java Doc)
public void close() throws IOException(Code)(Java Doc)
public synchronized void mark(int readlimit)(Code)(Java Doc)
public boolean markSupported()(Code)(Java Doc)
abstract public int read() throws IOException(Code)(Java Doc)
public int read(byte b) throws IOException(Code)(Java Doc)
public int read(byte b, int off, int len) throws IOException(Code)(Java Doc)
public synchronized void reset() throws IOException(Code)(Java Doc)
public long skip(long n) throws IOException(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.