예제 #1
0
 /**
  * automatically generate non-existing help html files for existing commands in the CommandLoader
  *
  * @param cl the CommandLoader where you look for the existing commands
  */
 public void createHelpText(CommandLoader cl) {
   File dir = new File((getClass().getResource("..").getPath()));
   dir = new File(dir, language);
   if (!dir.exists() && !dir.mkdirs()) {
     System.out.println("Failed to create " + dir.getAbsolutePath());
     return;
   }
   for (String mnemo : cl.getMnemoList()) {
     if (!exists(mnemo)) {
       File file = new File(dir, mnemo + ".htm");
       try {
         file.createNewFile();
         BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(file));
         PrintStream ps = new PrintStream(os);
         ps.println("<html>\n<head>\n<title>" + mnemo + "\n</title>\n</head>\n<body>");
         ps.println("Command: " + mnemo.toUpperCase() + "<br>");
         ps.println("arguments: <br>");
         ps.println("effects: <br>");
         ps.println("flags to be set: <br>");
         ps.println("approx. clockcycles: <br>");
         ps.println("misc: <br>");
         ps.println("</body>\n</html>");
         ps.flush();
         ps.close();
       } catch (IOException e) {
         System.out.println("failed to create " + file.getAbsolutePath());
       }
     }
   }
 }
예제 #2
0
파일: Util.java 프로젝트: denuno/railo-cli
 static String getResourceAsString(String path) {
   InputStream is = null;
   ByteArrayOutputStream out = new ByteArrayOutputStream();
   PrintStream outPrint = new PrintStream(out);
   try {
     is = Util.class.getClassLoader().getResourceAsStream(path);
     int content;
     while ((content = is.read()) != -1) {
       // convert to char and display it
       outPrint.print((char) content);
     }
   } catch (IOException e) {
     e.printStackTrace();
   } finally {
     try {
       if (is != null) is.close();
       if (outPrint != null) outPrint.close();
     } catch (IOException ex) {
       ex.printStackTrace();
     }
   }
   return out.toString();
 }