<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FFile%2FDataInputStream</id>
		<title>Java Tutorial/File/DataInputStream - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FFile%2FDataInputStream"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/File/DataInputStream&amp;action=history"/>
		<updated>2026-04-07T15:06:38Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/File/DataInputStream&amp;diff=5388&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/File/DataInputStream&amp;diff=5388&amp;oldid=prev"/>
				<updated>2010-06-01T05:20:14Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 05:20, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/File/DataInputStream&amp;diff=5387&amp;oldid=prev</id>
		<title> в 17:44, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/File/DataInputStream&amp;diff=5387&amp;oldid=prev"/>
				<updated>2010-05-31T17:44:27Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==  Check the class version ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.DataInputStream;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws IOException {&lt;br /&gt;
    DataInputStream in = new DataInputStream(new FileInputStream(&amp;quot;Main.class&amp;quot;));&lt;br /&gt;
    int start = in.readInt();&lt;br /&gt;
    if (start != 0xcafebabe) {&lt;br /&gt;
      System.out.println(&amp;quot;not valid&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    in.close();&lt;br /&gt;
    System.out.println(in.readUnsignedShort()+&amp;quot;/&amp;quot;+in.readUnsignedShort());&lt;br /&gt;
    &lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Create a compressed data file by using a DeflaterOutputStream and then read that data through an InflaterInputStream. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.DataInputStream;&lt;br /&gt;
import java.io.DataOutputStream;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
import java.io.FileOutputStream;&lt;br /&gt;
import java.util.zip.DeflaterOutputStream;&lt;br /&gt;
import java.util.zip.InflaterInputStream;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) throws Exception {&lt;br /&gt;
    double data[] = { 1.1, 2.2, 3.3, 4.4, 5.5, 6.6 };&lt;br /&gt;
    DataOutputStream fout = new DataOutputStream(new DeflaterOutputStream(new FileOutputStream(&lt;br /&gt;
        &amp;quot;data.dat&amp;quot;)));&lt;br /&gt;
    fout.writeInt(data.length);&lt;br /&gt;
    for (double d : data)&lt;br /&gt;
      fout.writeDouble(d);&lt;br /&gt;
    DataInputStream  fin = new DataInputStream(new InflaterInputStream(new FileInputStream(&lt;br /&gt;
        &amp;quot;data.dat&amp;quot;)));&lt;br /&gt;
    int num = fin.readInt();&lt;br /&gt;
    double avg = 0.0;&lt;br /&gt;
    double d;&lt;br /&gt;
    for (int i = 0; i &amp;lt; num; i++) {&lt;br /&gt;
      d = fin.readDouble();&lt;br /&gt;
      avg += d;&lt;br /&gt;
      System.out.print(d + &amp;quot; &amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    fin.close();&lt;br /&gt;
    fout.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Create DataInputStream from BufferedInputStream and FileInputStream ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.BufferedInputStream;&lt;br /&gt;
import java.io.DataInputStream;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) throws IOException {&lt;br /&gt;
    DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream(&lt;br /&gt;
        &amp;quot;temp.tmp&amp;quot;)));&lt;br /&gt;
    for (int i = 0; i &amp;lt; 10; i++)&lt;br /&gt;
      dis.readInt();&lt;br /&gt;
    dis.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Create DataInputStream from ByteArrayInputStream ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.ByteArrayInputStream;&lt;br /&gt;
import java.io.DataInputStream;&lt;br /&gt;
import java.io.EOFException;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) throws IOException {&lt;br /&gt;
    try {&lt;br /&gt;
      DataInputStream in3 = new DataInputStream(&lt;br /&gt;
        new ByteArrayInputStream(&amp;quot;a dbcde&amp;quot;.getBytes()));&lt;br /&gt;
      while(true)&lt;br /&gt;
        System.out.print((char)in3.readByte());&lt;br /&gt;
    } catch(EOFException e) {&lt;br /&gt;
      System.err.println(&amp;quot;End of stream&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
  }&lt;br /&gt;
}//&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;a dbcdeEnd of stream&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Create DataInputStream from FileInputStream ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.DataInputStream;&lt;br /&gt;
import java.io.EOFException;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    DataInputStream din = null;&lt;br /&gt;
    try {&lt;br /&gt;
      FileInputStream fin = new FileInputStream(&amp;quot;myfile.dat&amp;quot;);&lt;br /&gt;
      din = new DataInputStream(fin);&lt;br /&gt;
      while (true) {&lt;br /&gt;
        int theNumber = din.readInt();&lt;br /&gt;
        System.out.println(theNumber);&lt;br /&gt;
      }&lt;br /&gt;
    } catch (EOFException ex) {&lt;br /&gt;
      din.close();&lt;br /&gt;
    } catch (IOException ex) {&lt;br /&gt;
      System.err.println(ex);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Read boolean from file using DataInputStream ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.DataInputStream;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    FileInputStream fin = new FileInputStream(&amp;quot;C:/n.txt&amp;quot;);&lt;br /&gt;
    DataInputStream din = new DataInputStream(fin);&lt;br /&gt;
    boolean b = din.readBoolean();&lt;br /&gt;
    System.out.println(&amp;quot;boolean : &amp;quot; + b);&lt;br /&gt;
    din.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Read byte array from file using DataInputStream ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.DataInputStream;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    FileInputStream fin = new FileInputStream(&amp;quot;C:/Array.txt&amp;quot;);&lt;br /&gt;
    DataInputStream din = new DataInputStream(fin);&lt;br /&gt;
    byte b[] = new byte[10];&lt;br /&gt;
    din.read(b);&lt;br /&gt;
    din.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Read byte from file using DataInputStream ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.DataInputStream;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    FileInputStream fin = new FileInputStream(&amp;quot;C:/Byte.txt&amp;quot;);&lt;br /&gt;
    DataInputStream din = new DataInputStream(fin);&lt;br /&gt;
    byte b = din.readByte();&lt;br /&gt;
    System.out.println(&amp;quot;byte : &amp;quot; + b);&lt;br /&gt;
    din.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Read char from file using DataInputStream ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.DataInputStream;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception{&lt;br /&gt;
    FileInputStream fin = new FileInputStream(&amp;quot;C:/Char.txt&amp;quot;);&lt;br /&gt;
    DataInputStream din = new DataInputStream(fin);&lt;br /&gt;
    char ch = din.readChar();&lt;br /&gt;
    System.out.println(&amp;quot;Char : &amp;quot; + ch);&lt;br /&gt;
    din.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Read double and UTF from DataInputStream with BufferedInputStream backended ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.BufferedInputStream;&lt;br /&gt;
import java.io.BufferedOutputStream;&lt;br /&gt;
import java.io.DataInputStream;&lt;br /&gt;
import java.io.DataOutputStream;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
import java.io.FileOutputStream;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) throws IOException {&lt;br /&gt;
    DataOutputStream out2 = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(&lt;br /&gt;
        &amp;quot;Data.txt&amp;quot;)));&lt;br /&gt;
    out2.writeDouble(3.14159);&lt;br /&gt;
    out2.writeUTF(&amp;quot;Square root of 2&amp;quot;);&lt;br /&gt;
    out2.close();&lt;br /&gt;
    DataInputStream in5 = new DataInputStream(new BufferedInputStream(new FileInputStream(&lt;br /&gt;
        &amp;quot;Data.txt&amp;quot;)));&lt;br /&gt;
    System.out.println(in5.readDouble());&lt;br /&gt;
    System.out.println(in5.readUTF());&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Read double from DataInputStream ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.DataInputStream;&lt;br /&gt;
import java.io.EOFException;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    try {&lt;br /&gt;
      FileInputStream fin = new FileInputStream(&amp;quot;myFile.dat&amp;quot;);&lt;br /&gt;
      DataInputStream din = new DataInputStream(fin);&lt;br /&gt;
      while (true) {&lt;br /&gt;
        double theNumber = din.readDouble();&lt;br /&gt;
        System.out.println(theNumber);&lt;br /&gt;
      }&lt;br /&gt;
    } catch (EOFException e) {&lt;br /&gt;
    } catch (IOException e) {&lt;br /&gt;
      // abnormal termination&lt;br /&gt;
      System.err.println(e);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Read float from file using DataInputStream ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.DataInputStream;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    FileInputStream fin = new FileInputStream(&amp;quot;C:/Float.txt&amp;quot;);&lt;br /&gt;
    DataInputStream din = new DataInputStream(fin);&lt;br /&gt;
    float f = din.readFloat();&lt;br /&gt;
    System.out.println(&amp;quot;float : &amp;quot; + f);&lt;br /&gt;
    din.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Read int from DataInputStream ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.DataInputStream;&lt;br /&gt;
import java.io.EOFException;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    DataInputStream din = null;&lt;br /&gt;
    try {&lt;br /&gt;
      FileInputStream fin = new FileInputStream(&amp;quot;myfile.dat&amp;quot;);&lt;br /&gt;
      din = new DataInputStream(fin);&lt;br /&gt;
      while (true) {&lt;br /&gt;
        int theNumber = din.readInt();&lt;br /&gt;
        System.out.println(theNumber);&lt;br /&gt;
      }&lt;br /&gt;
    } catch (EOFException ex) {&lt;br /&gt;
      din.close();&lt;br /&gt;
    } catch (IOException ex) {&lt;br /&gt;
      System.err.println(ex);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Read long from file using DataInputStream ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.DataInputStream;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    FileInputStream fin = new FileInputStream(&amp;quot;C:/Long.txt&amp;quot;);&lt;br /&gt;
    DataInputStream din = new DataInputStream(fin);&lt;br /&gt;
    long l = din.readLong();&lt;br /&gt;
    System.out.println(&amp;quot;long : &amp;quot; + l);&lt;br /&gt;
    din.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Read short from file using DataInputStream ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.DataInputStream;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    FileInputStream fin = new FileInputStream(&amp;quot;C:/Short.txt&amp;quot;);&lt;br /&gt;
    DataInputStream din = new DataInputStream(fin);&lt;br /&gt;
    short s = din.readShort();&lt;br /&gt;
    System.out.println(&amp;quot;short : &amp;quot; + s);&lt;br /&gt;
    din.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Read unsigned byte from file using DataInputStream ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.DataInputStream;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    FileInputStream fin = new FileInputStream(&amp;quot;C:/UnsignedByte.txt&amp;quot;);&lt;br /&gt;
    DataInputStream din = new DataInputStream(fin);&lt;br /&gt;
    int i = din.readUnsignedByte();&lt;br /&gt;
    System.out.println(&amp;quot;Unsinged byte value : &amp;quot; + i);&lt;br /&gt;
    din.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Testing for end of file while reading a byte at a time. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.BufferedInputStream;&lt;br /&gt;
import java.io.DataInputStream;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) throws IOException {&lt;br /&gt;
    DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(&lt;br /&gt;
        &amp;quot;test.java&amp;quot;)));&lt;br /&gt;
    while (in.available() != 0)&lt;br /&gt;
      System.out.print((char) in.readByte());&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  This class is an part implementation of DataInput. It wraps a Reader object. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/* Copyright (c) 2001-2009, The HSQL Development Group&lt;br /&gt;
 * All rights reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions are met:&lt;br /&gt;
 *&lt;br /&gt;
 * Redistributions of source code must retain the above copyright notice, this&lt;br /&gt;
 * list of conditions and the following disclaimer.&lt;br /&gt;
 *&lt;br /&gt;
 * Redistributions in binary form must reproduce the above copyright notice,&lt;br /&gt;
 * this list of conditions and the following disclaimer in the documentation&lt;br /&gt;
 * and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 * Neither the name of the HSQL Development Group nor the names of its&lt;br /&gt;
 * contributors may be used to endorse or promote products derived from this&lt;br /&gt;
 * software without specific prior written permission.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS IS&amp;quot;&lt;br /&gt;
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE&lt;br /&gt;
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE&lt;br /&gt;
 * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,&lt;br /&gt;
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,&lt;br /&gt;
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;&lt;br /&gt;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND&lt;br /&gt;
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT&lt;br /&gt;
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS&lt;br /&gt;
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.io.DataInput;&lt;br /&gt;
import java.io.EOFException;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.io.Reader;&lt;br /&gt;
/**&lt;br /&gt;
 * This class is an part implementation of DataInput. It wraps a Reader object.&lt;br /&gt;
 *&lt;br /&gt;
 * @author Fred Toussi (fredt@users dot sourceforge.net)&lt;br /&gt;
 * @version 1.9.0&lt;br /&gt;
 * @since 1.9.0&lt;br /&gt;
 */&lt;br /&gt;
public class ReaderDataInput implements DataInput {&lt;br /&gt;
    protected Reader reader;&lt;br /&gt;
    protected int    pos;&lt;br /&gt;
    int              lastChar = -1;&lt;br /&gt;
    public ReaderDataInput(Reader reader) {&lt;br /&gt;
        this.reader = reader;&lt;br /&gt;
        this.pos    = 0;&lt;br /&gt;
    }&lt;br /&gt;
    // methods that implement java.io.DataInput&lt;br /&gt;
    public final void readFully(byte[] b) throws IOException {&lt;br /&gt;
        readFully(b, 0, b.length);&lt;br /&gt;
    }&lt;br /&gt;
    public final void readFully(byte[] bytes, int off,&lt;br /&gt;
                                int len) throws IOException {&lt;br /&gt;
        if (len &amp;lt; 0) {&lt;br /&gt;
            throw new IndexOutOfBoundsException();&lt;br /&gt;
        }&lt;br /&gt;
        int n = 0;&lt;br /&gt;
        while (n &amp;lt; len) {&lt;br /&gt;
            int b = read();&lt;br /&gt;
            if (b &amp;lt; 0) {&lt;br /&gt;
                throw new EOFException();&lt;br /&gt;
            }&lt;br /&gt;
            bytes[off + n++] = (byte) b;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    public final boolean readBoolean() throws IOException {&lt;br /&gt;
        int b = read();&lt;br /&gt;
        if (b &amp;lt; 0) {&lt;br /&gt;
            throw new EOFException();&lt;br /&gt;
        }&lt;br /&gt;
        return (b != 0);&lt;br /&gt;
    }&lt;br /&gt;
    public final byte readByte() throws IOException {&lt;br /&gt;
        int b = read();&lt;br /&gt;
        if (b &amp;lt; 0) {&lt;br /&gt;
            throw new EOFException();&lt;br /&gt;
        }&lt;br /&gt;
        return (byte) b;&lt;br /&gt;
    }&lt;br /&gt;
    public final int readUnsignedByte() throws IOException {&lt;br /&gt;
        int b = read();&lt;br /&gt;
        if (b &amp;lt; 0) {&lt;br /&gt;
            throw new EOFException();&lt;br /&gt;
        }&lt;br /&gt;
        return b;&lt;br /&gt;
    }&lt;br /&gt;
    public short readShort() throws IOException {&lt;br /&gt;
        int b1 = read();&lt;br /&gt;
        if (b1 &amp;lt; 0) {&lt;br /&gt;
            throw new EOFException();&lt;br /&gt;
        }&lt;br /&gt;
        int b2 = read();&lt;br /&gt;
        if (b2 &amp;lt; 0) {&lt;br /&gt;
            throw new EOFException();&lt;br /&gt;
        }&lt;br /&gt;
        return (short) ((b1 &amp;lt;&amp;lt; 8) | b2);&lt;br /&gt;
    }&lt;br /&gt;
    public final int readUnsignedShort() throws IOException {&lt;br /&gt;
        int b1 = read();&lt;br /&gt;
        int b2 = read();&lt;br /&gt;
        if ((b1 | b2) &amp;lt; 0) {&lt;br /&gt;
            throw new EOFException();&lt;br /&gt;
        }&lt;br /&gt;
        return ((b1 &amp;lt;&amp;lt; 8) + (b2));&lt;br /&gt;
    }&lt;br /&gt;
    public final char readChar() throws IOException {&lt;br /&gt;
        int b1 = read();&lt;br /&gt;
        int b2 = read();&lt;br /&gt;
        if ((b1 | b2) &amp;lt; 0) {&lt;br /&gt;
            throw new EOFException();&lt;br /&gt;
        }&lt;br /&gt;
        return (char) ((b1 &amp;lt;&amp;lt; 8) + (b2));&lt;br /&gt;
    }&lt;br /&gt;
    public int readInt() throws IOException {&lt;br /&gt;
        throw new java.lang.RuntimeException(&amp;quot;not implemented.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public long readLong() throws IOException {&lt;br /&gt;
        throw new java.lang.RuntimeException(&amp;quot;not implemented.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public final float readFloat() throws IOException {&lt;br /&gt;
        throw new java.lang.RuntimeException(&amp;quot;not implemented.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public final double readDouble() throws IOException {&lt;br /&gt;
        throw new java.lang.RuntimeException(&amp;quot;not implemented.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public int skipBytes(int n) throws IOException {&lt;br /&gt;
        throw new java.lang.RuntimeException(&amp;quot;not implemented.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public String readLine() throws IOException {&lt;br /&gt;
        throw new java.lang.RuntimeException(&amp;quot;not implemented.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public String readUTF() throws IOException {&lt;br /&gt;
        throw new java.lang.RuntimeException(&amp;quot;not implemented.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public int read() throws IOException {&lt;br /&gt;
        if (lastChar &amp;gt;= 0) {&lt;br /&gt;
            int val = lastChar &amp;amp; 0xff;&lt;br /&gt;
            lastChar = -1;&lt;br /&gt;
            pos++;&lt;br /&gt;
            return val;&lt;br /&gt;
        }&lt;br /&gt;
        lastChar = reader.read();&lt;br /&gt;
        if (lastChar &amp;lt; 0) {&lt;br /&gt;
            return lastChar;&lt;br /&gt;
        }&lt;br /&gt;
        pos++;&lt;br /&gt;
        return lastChar &amp;gt;&amp;gt; 8;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Use DataInputStream to create double ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.DataInputStream;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) throws Exception {&lt;br /&gt;
    FileInputStream fileIn = new FileInputStream(&amp;quot;data.txt&amp;quot;);&lt;br /&gt;
    DataInputStream dataIn = new DataInputStream(fileIn);&lt;br /&gt;
    System.out.println(dataIn.readUTF());&lt;br /&gt;
    int counter = dataIn.readInt();&lt;br /&gt;
    double sum = 0.0;&lt;br /&gt;
    for (int i = 0; i &amp;lt; counter; i++) {&lt;br /&gt;
      double current = dataIn.readDouble();&lt;br /&gt;
      System.out.println(&amp;quot;Just read &amp;quot; + current);&lt;br /&gt;
      sum += current;&lt;br /&gt;
    }&lt;br /&gt;
    System.out.println(&amp;quot;\nAverage = &amp;quot; + sum / counter);&lt;br /&gt;
    dataIn.close();&lt;br /&gt;
    fileIn.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>