Browse Source

Correcting use of deprecated API.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@426172 13f79535-47bb-0310-9956-ffa450edef68
master
Jesse N. Glick 19 years ago
parent
commit
ea98aac2fa
1 changed files with 7 additions and 8 deletions
  1. +7
    -8
      src/main/org/apache/tools/ant/input/DefaultInputHandler.java

+ 7
- 8
src/main/org/apache/tools/ant/input/DefaultInputHandler.java View File

@@ -17,12 +17,12 @@


package org.apache.tools.ant.input; package org.apache.tools.ant.input;


import java.io.DataInputStream;
import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Enumeration; import java.util.Enumeration;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.util.KeepAliveInputStream;


/** /**
* Prompts on System.err, reads input from System.in * Prompts on System.err, reads input from System.in
@@ -45,15 +45,14 @@ public class DefaultInputHandler implements InputHandler {
*/ */
public void handleInput(InputRequest request) throws BuildException { public void handleInput(InputRequest request) throws BuildException {
String prompt = getPrompt(request); String prompt = getPrompt(request);
DataInputStream in = null;
BufferedReader r = null;
try { try {
in =
new DataInputStream(new KeepAliveInputStream(getInputStream()));
r = new BufferedReader(new InputStreamReader(getInputStream()));
do { do {
System.err.println(prompt); System.err.println(prompt);
System.err.flush(); System.err.flush();
try { try {
String input = in.readLine();
String input = r.readLine();
request.setInput(input); request.setInput(input);
} catch (IOException e) { } catch (IOException e) {
throw new BuildException("Failed to read input from" throw new BuildException("Failed to read input from"
@@ -61,9 +60,9 @@ public class DefaultInputHandler implements InputHandler {
} }
} while (!request.isInputValid()); } while (!request.isInputValid());
} finally { } finally {
if (in != null) {
if (r != null) {
try { try {
in.close();
r.close();
} catch (IOException e) { } catch (IOException e) {
throw new BuildException("Failed to close input.", e); throw new BuildException("Failed to close input.", e);
} }


Loading…
Cancel
Save