Java IO Tutorial - Java FilterWriter.write(String str, int off, int len)








Syntax

FilterWriter.write(String str, int off, int len) has the following syntax.

public void write(String str,  int off,  int len)  throws IOException

Example

In the following code shows how to use FilterWriter.write(String str, int off, int len) method.

/*from w  ww.j  av a2s  .co m*/
import java.io.FilterWriter;
import java.io.StringWriter;
import java.io.Writer;

public class Main {
  public static void main(String[] args) throws Exception {

    String str = "from java2s.com";
    Writer w = new StringWriter(6);

    FilterWriter fw = new FilterWriter(w) {
    };

    fw.write(str, 5, 7);

    String  s = w.toString();

    System.out.print(s);

  }
}

The code above generates the following result.