Click here to watch in Youtube :
https://www.youtube.com/watch?v=aEgiHFWUJF8&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java IO (PrintStream) |
Java Tutorial : Java IO (PrintStream) |
Java Tutorial : Java IO (PrintStream) |
Java Tutorial : Java IO (PrintStream) |
Java Tutorial : Java IO (PrintStream) |
Java Tutorial : Java IO (PrintStream) |
Java Tutorial : Java IO (PrintStream) |
import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; public class PrintStreamDemo { public static void main(String[] args) throws IOException { FileOutputStream fileOutputStream = null; PrintStream printStream = null; try { fileOutputStream = new FileOutputStream("myfile.txt"); printStream = new PrintStream(fileOutputStream); /* * Prints an integer and then terminate the * line. */ printStream.println(2500); /* * Prints a String and then terminate the line. */ printStream.println("Hello Peter"); /* * Prints a double and then terminate the line. */ printStream.println(25.988); /* * Prints a boolean and then terminate the line. */ printStream.println(true); System.out.println("Successfully written to the file." + "please check the file content"); } finally { if (fileOutputStream != null) { fileOutputStream.close(); } if (printStream != null) { printStream.close(); } } } }Output
Successfully written to the file.please check the file content
myfile.txt
2500 Hello Peter 25.988 trueRefer:
https://docs.oracle.com/javase/8/docs/api/index.html?java/io/PrintStream.html
https://sites.google.com/site/ramj2eev1/home/javabasics/JavaIODemo_PrintStream_intro_app.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/JavaIODemo_PrintStream_intro_app
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/6677706d119a4693a72878c56e3b8b5e20670e29/BasicJava/JavaIODemo_PrintStream_intro_app/?at=master
See also:
No comments:
Post a Comment