PrintWriter.write(String s, int off, int len) has the following syntax.
public void write(String s, int off, int len)
In the following code shows how to use PrintWriter.write(String s, int off, int len) method.
/*from ww w . j a va 2s.co m*/ import java.io.*; public class Main { public static void main(String[] args) { String s = "tutorial from java2s.com"; try { PrintWriter pw = new PrintWriter(System.out); // write substrings pw.write(s, 0, 5); pw.write(s, 6, 5); // flush the writer pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } } }
The code above generates the following result.