1 package org.cyclopsgroup.jmxterm.io;
2
3 import java.io.File;
4 import java.io.FileNotFoundException;
5 import java.io.FileReader;
6 import java.io.IOException;
7 import java.io.LineNumberReader;
8 import org.apache.commons.lang3.Validate;
9
10
11
12
13
14
15 public class FileCommandInput extends CommandInput {
16 private final LineNumberReader in;
17
18
19
20
21
22
23
24 public FileCommandInput(File inputFile) throws FileNotFoundException {
25 Validate.notNull(inputFile, "Input can't be NULL");
26 this.in = new LineNumberReader(new FileReader(inputFile));
27 }
28
29 @Override
30 public void close() throws IOException {
31 in.close();
32 }
33
34 @Override
35 public String readLine() throws IOException {
36 return in.readLine();
37 }
38
39 @Override
40 public String readMaskedString(String prompt) throws IOException {
41 throw new UnsupportedOperationException("Reading password from a file is not supported");
42 }
43 }