diff --git a/stringwriter.java b/stringwriter.java new file mode 100644 index 0000000..6aa0b80 --- /dev/null +++ b/stringwriter.java @@ -0,0 +1,25 @@ +import java.io.StringWriter; + +public class Main { + public static void main(String[] args) { + + String data = "This is the text in the string."; + + try { + // Create a StringWriter with default string buffer capacity + StringWriter output = new StringWriter(); + + // Writes data to the string buffer + output.write(data); + + // Prints the string writer + System.out.println("Data in the StringWriter: " + output); + + output.close(); + } + + catch(Exception e) { + e.getStackTrace(); + } + } +}