User Tools

Site Tools


java:io:printstream:write

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

java:io:printstream:write [2012/11/23 13:47]
127.0.0.1 external edit
java:io:printstream:write [2013/09/09 09:07] (current)
202.142.91.21 [Language Example]
Line 12: Line 12:
 <code java> <code java>
  
-      try {+      try(    //Try-with-resource-block 
 +            FileWriter stream = new FileWriter("output.txt"); // create file  
 +            BufferedWriter output = new BufferedWriter(stream); 
 +         ) {
            
-        FileWriter stream = new FileWriter("output.txt"); // create file  
-        BufferedWriter output = new BufferedWriter(stream); 
-         
         output.write("Hello Harddisk");             // Write to Stream         output.write("Hello Harddisk");             // Write to Stream
-        output.close();                             //Close the output stream+       //This is an auto-closable block so no need of "output.close();"
        }        }
        catch (Exception e){        catch (Exception e){
advertising
java/io/printstream/write.txt · Last modified: 2013/09/09 09:07 by 202.142.91.21

Impressum Datenschutz