- String [] cmd = {
- "/bin/sh", "-c", "stty size < /dev/tty"
- };
- try {
- Process process = Runtime.getRuntime().exec(cmd);
- BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8"));
- String line = in.readLine();
- if ((line != null) && (line.length() > 0)) {
- StringTokenizer tokenizer = new StringTokenizer(line);
- windowHeight = Integer.parseInt(tokenizer.nextToken());
- windowWidth = Integer.parseInt(tokenizer.nextToken());
- }
- while (true) {
- BufferedReader err = new BufferedReader(new InputStreamReader(process.getErrorStream(), "UTF-8"));
- line = err.readLine();
- if ((line != null) && (line.length() > 0)) {
- System.err.println("Error output from stty: " + line);
- }
- try{
- process.waitFor();
- break;
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- int rc = process.exitValue();
- if (rc != 0) {
- System.err.println("stty returned error code: " + rc);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
+ String [] cmd = {
+ "/bin/sh", "-c", "stty size < /dev/tty"
+ };
+ try {
+ Process process = Runtime.getRuntime().exec(cmd);
+ BufferedReader in = new BufferedReader(
+ new InputStreamReader(process.getInputStream(), "UTF-8"));
+ String line = in.readLine();
+ if ((line != null) && (line.length() > 0)) {
+ StringTokenizer tokenizer = new StringTokenizer(line);
+ windowHeight = Integer.parseInt(tokenizer.nextToken());
+ windowWidth = Integer.parseInt(tokenizer.nextToken());
+ }
+ while (true) {
+ BufferedReader err = new BufferedReader(
+ new InputStreamReader(process.getErrorStream(),
+ "UTF-8"));
+ line = err.readLine();
+ if ((line != null) && (line.length() > 0)) {
+ System.err.println("Error output from stty: " + line);
+ }
+ try {
+ process.waitFor();
+ break;
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ int rc = process.exitValue();
+ if (rc != 0) {
+ System.err.println("stty returned error code: " + rc);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }