Example usage for java.io DataOutputStream close

List of usage examples for java.io DataOutputStream close

Introduction

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

Prototype

@Override
public void close() throws IOException 

Source Link

Document

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

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    FileOutputStream fos = new FileOutputStream("C:/WriteByte.txt");
    DataOutputStream dos = new DataOutputStream(fos);

    int i = 1;/*from  w w  w. j  a v a  2 s. c o m*/
    dos.writeByte(i);
    dos.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    FileOutputStream fos = new FileOutputStream("C:/Int.txt");
    DataOutputStream dos = new DataOutputStream(fos);

    int i = 100;/*from   w  w w .  ja v  a 2s .com*/
    dos.writeInt(i);
    dos.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    FileOutputStream fos = new FileOutputStream("C:/WriteLong.txt");
    DataOutputStream dos = new DataOutputStream(fos);

    long l = 65;//from www . ja v a2s  .  c o m
    dos.writeLong(l);
    dos.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    FileOutputStream fos = new FileOutputStream("C:/WriteChar.txt");
    DataOutputStream dos = new DataOutputStream(fos);

    int ch = 65;// w ww  .j  ava 2s .  com
    dos.writeChar(ch);
    dos.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    FileOutputStream fos = new FileOutputStream("C:/WriteShort.txt");
    DataOutputStream dos = new DataOutputStream(fos);

    short s = 1;/* w ww . j a v  a 2 s  .co  m*/
    dos.writeShort(s);
    dos.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String strFilePath = "C:/Double.txt";
    FileOutputStream fos = new FileOutputStream(strFilePath);
    DataOutputStream dos = new DataOutputStream(fos);
    double d = 1;
    dos.writeDouble(d);/*from  w  w w  . ja  v a 2  s  .  c  o m*/
    dos.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    FileOutputStream fos = new FileOutputStream("C:/WriteFloat.txt");
    DataOutputStream dos = new DataOutputStream(fos);

    float f = 5.314f;
    dos.writeFloat(f);/*  w ww  .  java 2s.  co m*/
    dos.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    FileOutputStream fos = new FileOutputStream("C:/WriteBoolean.txt");
    DataOutputStream dos = new DataOutputStream(fos);

    boolean b = false;
    dos.writeBoolean(b);//w  w  w.j  a v  a2  s .c o m
    dos.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    FileOutputStream fos = new FileOutputStream("C:/WriteByte.txt");
    DataOutputStream dos = new DataOutputStream(fos);
    dos.writeBytes("this is a test");

    dos.flush();//from w  w  w  .jav  a  2 s. c o  m
    dos.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    FileOutputStream fos = new FileOutputStream("C:/Chars.txt");
    DataOutputStream dos = new DataOutputStream(fos);

    String str = "this is a test";
    dos.writeChars(str);/* ww w.jav  a  2s  .  c o  m*/
    dos.close();
}