View Javadoc
1   package calculator.command;
2   
3   import java.io.InputStream;
4   import java.util.Scanner;
5   
6   public class HelpCommand implements CLICommand {
7   	@Override
8   	public boolean execute(String args) {
9   
10  		// gets the resource file help.txt at src/main/resources/help.txt
11  		// and renders it
12  		ClassLoader classloader = Thread.currentThread().getContextClassLoader();
13  		InputStream is = classloader.getResourceAsStream("help.txt");
14  		try (Scanner myReader = new Scanner(is)) {
15  			while (myReader.hasNextLine()) {
16  				String data = myReader.nextLine();
17  				System.out.println(data);
18  			}
19  		}
20  
21  		return true;
22  	}
23  }