Example usage for java.io FileOutputStream FileOutputStream

List of usage examples for java.io FileOutputStream FileOutputStream

Introduction

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

Prototype

public FileOutputStream(FileDescriptor fdObj) 

Source Link

Document

Creates a file output stream to write to the specified file descriptor, which represents an existing connection to an actual file in the file system.

Usage

From source file:Main.java

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

    DataOutputStream dos = new DataOutputStream(fos);
}

From source file:Main.java

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

    FileOutputStream f = new FileOutputStream("file.txt");

    System.setOut(new PrintStream(f));

    System.out.println("This is from java2s.com");
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    System.setErr(new PrintStream(new FileOutputStream("system_err.txt")));

    String nullString = null;//w w w.ja v  a2  s  .c o  m
    nullString = nullString.toUpperCase();
}

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 2s  .co  m
    dos.writeByte(i);
    dos.close();
}

From source file:Main.java

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

    FileOutputStream fos = new FileOutputStream(args[0]);

    DataOutputStream dos = new DataOutputStream(fos);

    dos.writeShort(1);/*from   ww w.j  av  a2s  .  c om*/

    fos.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;/*from w w w.  j  ava  2s  . c om*/
    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;/*ww  w . ja  v  a  2 s  . c o  m*/
    dos.writeShort(s);
    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 ww.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:/Chars.txt");
    DataOutputStream dos = new DataOutputStream(fos);

    String str = "this is a test";
    dos.writeChars(str);/*w  w w.j  av a 2s .  c o m*/
    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;/*ww w.j  ava 2s. co  m*/
    dos.writeLong(l);
    dos.close();
}