Java StringWriter

StringWriter is similar to StringBuffer, which can collect a host of string values and work with the data. We will explore writing a porting of a given string.

Code sample:

import java.io.StringWriter;public class UsingStringWriter{   public static void main(String args[])   {      UsingStringWriter usingStringWriter = new UsingStringWriter();      usingStringWriter.proceed();   }      private void proceed()   {      String welcomeString = "Welcome";            StringWriter stringWriter = new StringWriter();            stringWriter.write(welcomeString);      System.out.println(stringWriter.toString());   }}/*

Expected output:

[[email protected]]# java UsingStringWriterWelcome*/
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: