Changeset 1341 for trunk/java-utils/src/main
- Timestamp:
- 01/28/14 16:09:19 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/java-utils/src/main/java/de/ugoe/cs/util/console/defaultcommands/CMDman.java
r927 r1341 15 15 package de.ugoe.cs.util.console.defaultcommands; 16 16 17 import java.io.BufferedReader; 17 18 import java.io.IOException; 18 19 import java.io.InputStream; 20 import java.io.InputStreamReader; 19 21 import java.util.List; 20 22 21 import org.apache.commons.io.IOUtils;22 23 import org.apache.commons.lang.WordUtils; 23 24 … … 56 57 InputStream manStream = 57 58 ClassLoader.getSystemResourceAsStream("manuals/" + command); 59 58 60 if (manStream != null) { 61 BufferedReader reader = new BufferedReader(new InputStreamReader(manStream)); 59 62 try { 60 Console.println(WordUtils.wrap(IOUtils.toString(manStream, "UTF-8"), 100).replace("$USAGE$", "Usage: " + cmd.help())); 63 String line = reader.readLine(); 64 65 while (line != null) { 66 line = line.replace("$USAGE$", "Usage: " + cmd.help()); 67 Console.println(WordUtils.wrap(line, 100)); 68 line = reader.readLine(); 69 } 61 70 } 62 71 catch (IOException e) { … … 64 73 Console.logException(e); 65 74 } 75 finally { 76 try { 77 reader.close(); 78 } 79 catch (IOException e) { 80 // Ignore, as this is unimportant to the user 81 } 82 } 66 83 } 67 84 else { 68 Console.println(" Usage: " + help());85 Console.println("No man page for command " + command + " available"); 69 86 } 70 87 }
Note: See TracChangeset
for help on using the changeset viewer.