< prev index next >
src/java.base/share/classes/java/io/Console.java
Print this page
rev 51515 : 8209937: Enhance java.io.Console - provide methods to query console width and height
Contributed-by: christoph.langer@sap.com, matthias.baesken@sap.com
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -23,12 +23,15 @@
* questions.
*/
package java.io;
-import java.util.*;
import java.nio.charset.Charset;
+import java.util.Arrays;
+import java.util.Formatter;
+import java.util.IllegalFormatException;
+
import jdk.internal.misc.JavaIOAccess;
import jdk.internal.misc.SharedSecrets;
import sun.nio.cs.StreamDecoder;
import sun.nio.cs.StreamEncoder;
@@ -388,10 +391,24 @@
*/
public void flush() {
pw.flush();
}
+ /**
+ * Obtains the width of the console window.
+ *
+ * @return The width or -1 if it cannot be obtained.
+ */
+ public native int width();
+
+ /**
+ * Obtains the height of the console window.
+ *
+ * @return The height or -1 if it cannot be obtained.
+ */
+ public native int height();
+
private Object readLock;
private Object writeLock;
private Reader reader;
private Writer out;
private PrintWriter pw;
@@ -399,10 +416,11 @@
private Charset cs;
private char[] rcb;
private boolean restoreEcho;
private boolean shutdownHookInstalled;
private static native String encoding();
+
/*
* Sets the console echo status to {@code on} and returns the previous
* console on/off status.
* @param on the echo status to set to. {@code true} for echo on and
* {@code false} for echo off
< prev index next >