Firstly, these links will be helpful for read data from file:
Reading a plain text file in Java
Reading and displaying data from a .txt file
Secondly, these links will be helpful for get input from command line:
How to get input via command line in Java?
How can I get the user input in Java?
And the last, a simple code sample:
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
ArrayList<String> list = new ArrayList<>();
try (BufferedReader br = new BufferedReader(new FileReader("list.txt"))) {
String sCurrentLine;
while ((sCurrentLine = br.readLine()) != null) {
list.add(sCurrentLine.trim());
}
System.out.print("Enter name: ");
String name = scanner.next();
for (int i = 0; i < list.size(); i++) {
String s = list.get(i);
if (s.equals(name.trim())) {
System.out.println("phone number: " + list.get(i + 1));
break;
}
}
} catch (IOException e) {
e.printStackTrace();
}
}