Click here to watch in Youtube :
https://www.youtube.com/watch?v=Ilkr-XYW1BM&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java IO (StringWriter) |
Java Tutorial : Java IO (StringWriter) |
import java.io.StringWriter; public class StringWriterDemo { public static void main(String[] args) throws Exception { StringWriter stringWriter = null; try { /* * Create a new string writer using the default * initial string-buffer size. */ stringWriter = new StringWriter(); // write characters to writer. stringWriter.write("Welcome to India"); /* * Return the buffer's current value as a * string. */ String str = stringWriter.toString(); System.out.println("str = " + str); /* * Returns: StringBuffer holding the current * buffer value. */ StringBuffer sb = stringWriter.getBuffer(); System.out.println("sb = " + sb); } finally { if (stringWriter != null) { stringWriter.close(); } } } }Output
str = Welcome to India sb = Welcome to IndiaRefer:
https://docs.oracle.com/javase/8/docs/api/index.html?java/io/StringWriter.html
https://sites.google.com/site/ramj2eev1/home/javabasics/JavaIODemo_StringWriter_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/JavaIODemo_StringWriter_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/301d989d72a8b053f20342cfe0bd4a5c143c23aa/BasicJava/JavaIODemo_StringWriter_App/?at=master
See also:
No comments:
Post a Comment