Example usage for java.io DataInputStream close

List of usage examples for java.io DataInputStream close

Introduction

In this page you can find the example usage for java.io DataInputStream close.

Prototype

public void close() throws IOException 

Source Link

Document

Closes this input stream and releases any system resources associated with the stream.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    FileInputStream fin = new FileInputStream("C:/Array.txt");
    DataInputStream din = new DataInputStream(fin);

    byte b[] = new byte[10];
    din.read(b);/*from   w w  w  . j  a  v  a2s  .  co  m*/
    din.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    FileInputStream fin = new FileInputStream("C:/Long.txt");
    DataInputStream din = new DataInputStream(fin);
    long l = din.readLong();
    System.out.println("long : " + l);
    din.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    FileInputStream fin = new FileInputStream("C:/Short.txt");
    DataInputStream din = new DataInputStream(fin);

    short s = din.readShort();
    System.out.println("short : " + s);
    din.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    FileInputStream fin = new FileInputStream("C:/Float.txt");
    DataInputStream din = new DataInputStream(fin);

    float f = din.readFloat();
    System.out.println("float : " + f);
    din.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {

    DataInputStream in3 = new DataInputStream(new ByteArrayInputStream("a dbcde".getBytes()));
    System.out.print((char) in3.readByte());
    in3.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Socket sock = new Socket(args[0], 1234);
    DataInputStream dis = new DataInputStream(sock.getInputStream());
    float f = dis.readFloat();
    System.out.println("PI=" + f);
    dis.close();
    sock.close();/*from   w  ww  . j a  v a  2s.  c om*/
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    FileInputStream fin = new FileInputStream("C:/UnsignedByte.txt");
    DataInputStream din = new DataInputStream(fin);

    int i = din.readUnsignedByte();
    System.out.println("Unsinged byte value : " + i);
    din.close();
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    String sessionCookie = null;//from   www .ja va2 s  .  com
    URL url = new java.net.URL("http://127.0.0.1/yourServlet");
    URLConnection con = url.openConnection();
    if (sessionCookie != null) {
        con.setRequestProperty("cookie", sessionCookie);
    }
    con.setUseCaches(false);
    con.setDoOutput(true);
    con.setDoInput(true);
    ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
    DataOutputStream out = new DataOutputStream(byteOut);
    out.flush();
    byte buf[] = byteOut.toByteArray();
    con.setRequestProperty("Content-type", "application/octet-stream");
    con.setRequestProperty("Content-length", "" + buf.length);
    DataOutputStream dataOut = new DataOutputStream(con.getOutputStream());
    dataOut.write(buf);
    dataOut.flush();
    dataOut.close();
    DataInputStream in = new DataInputStream(con.getInputStream());
    int count = in.readInt();
    in.close();
    if (sessionCookie == null) {
        String cookie = con.getHeaderField("set-cookie");
        if (cookie != null) {
            sessionCookie = parseCookie(cookie);
            System.out.println("Setting session ID=" + sessionCookie);
        }
    }

    System.out.println(count);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream("temp.tmp")));
    for (int i = 0; i < 10; i++)
        dis.readInt();/*from www  .  j a v  a 2s.  co  m*/
    dis.close();

}

From source file:Main.java

public static void main(String[] args) throws IOException {
    DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream("temp.tmp")));
    for (int i = 0; i < 10; i++)
        dis.readInt();//from   w w w . ja  va2s. com
    dis.close();

}