Click here to watch in Youtube :
https://www.youtube.com/watch?v=76R9GT9rZOU&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java IO (PrintWriter) |
Java Tutorial : Java IO (PrintWriter) |
Java Tutorial : Java IO (PrintWriter) |
Java Tutorial : Java IO (PrintWriter) |
Java Tutorial : Java IO (PrintWriter) |
Java Tutorial : Java IO (PrintWriter) |
Java Tutorial : Java IO (PrintWriter) |
https://docs.oracle.com/javase/8/docs/api/index.html?java/io/PrintWriter.html
PrintWriterDemo.java
import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; public class PrintWriterDemo { public static void main(String[] args) throws IOException { FileWriter fileWriter = null; PrintWriter printWriter = null; try { fileWriter = new FileWriter("myoutputfile.txt"); printWriter = new PrintWriter(fileWriter); printWriter.println(true); printWriter.println((int) 123); printWriter.println((float) 123.456); int intValue = 98; double doubleValue = 899.87; /* * public PrintWriter printf(String format, * Object... args) * * A convenience method to write a formatted * string to this writer using the specified * format string and arguments. */ printWriter.printf("i = %d and k = %f", intValue, doubleValue); System.out.println("Successfully written to the file." + "please check the file \'myoutputfile.txt\'"); } finally { if (fileWriter != null) { fileWriter.close(); } if (printWriter != null) { printWriter.close(); } } } }Output
Successfully written to the file.please check the file 'myoutputfile.txt'myoutputfile.txt
true 123 123.456 i = 98 and k = 899.870000
https://sites.google.com/site/ramj2eev1/home/javabasics/JavaIODemo_PrintWriter_Intro_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/JavaIODemo_PrintWriter_Intro_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/6677706d119a4693a72878c56e3b8b5e20670e29/BasicJava/JavaIODemo_PrintWriter_Intro_App/?at=master
See also:
No comments:
Post a Comment