User Tools

Site Tools


Programming Reference/Librarys

Question & Answer

Q&A is closed


Table of Contents


Writes count or one byte to target stream/buffer.

write(int oneByte);
write(byte[] buffer, int offset, int length);

Language Example

      try(    //Try-with-resource-block
            FileWriter stream = new FileWriter("output.txt"); // create file 
            BufferedWriter output = new BufferedWriter(stream);
         ) {
        output.write("Hello Harddisk");             // Write to Stream
       //This is an auto-closable block so no need of "output.close();"
       catch (Exception e){
            System.err.println("Error: " + e.getMessage());


  file content: Hello Harddisk
  or on console, e.g. on a Android System
  System.err Error: /output.txt (Read-only file system)

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
java/io/printstream/write.txt · Last modified: 2024/02/16 01:12 (external edit)

Impressum Datenschutz