Home » Tip Bank » Java
  • Comment on this Article
Language: Java
Expertise: Intermediate
Aug 6, 2019
  • facebook
  • twitter
  • in
  • Email

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Watch

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:

[root@mypc]# java UsingStringWriter
Welcome

*/
M S Sridhar
 
Submit a Tip
Browse "Java" Tips
Browse All Tips
html.net
html-color-codes.info