1 /* 2 * Copyright (c) 2002-2017, the original author or authors. 3 * 4 * This software is distributable under the BSD license. See the terms of the 5 * BSD license in the documentation provided with this software. 6 * 7 * https://opensource.org/licenses/BSD-3-Clause 8 */ 9 package jdk.internal.org.jline.terminal.impl; 10 11 import java.io.IOException; 12 import java.io.Writer; 13 14 public abstract class AbstractWindowsConsoleWriter extends Writer { 15 writeConsole(char[] text, int len)16 protected abstract void writeConsole(char[] text, int len) throws IOException; 17 18 @Override write(char[] cbuf, int off, int len)19 public void write(char[] cbuf, int off, int len) throws IOException { 20 char[] text = cbuf; 21 if (off != 0) { 22 text = new char[len]; 23 System.arraycopy(cbuf, off, text, 0, len); 24 } 25 26 synchronized (this.lock) { 27 writeConsole(text, len); 28 } 29 } 30 31 @Override flush()32 public void flush() { 33 } 34 35 @Override close()36 public void close() { 37 } 38 39 } 40