Java StringWriter.write(String str, int off, int len)
Syntax
StringWriter.write(String str, int off, int len) has the following syntax.
public void write(String str, int off, int len)
Example
In the following code shows how to use StringWriter.write(String str, int off, int len) method.
/*from ww w. ja v a2 s . c o m*/
import java.io.*;
public class Main {
public static void main(String[] args) {
String s = "tutorial from java2s.com";
StringWriter sw = new StringWriter();
// write strings
sw.write(s, 0, 4);
sw.write(s, 5, 6);
System.out.println(sw.toString());
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »