コード例 #1
0
  public String execute() throws Exception {
    String path = this.getServletContext().getRealPath("/");
    File dir = new File(path + "/resource/news");
    String[] picFileNames = dir.list();
    if (Detect.notEmpty(picFileNames)) {
      Random r = new Random(System.currentTimeMillis());
      int seq = r.nextInt(picFileNames.length);
      picFileName = picFileNames[seq];
    } else {
      picFileName = "default.jpg";
    }

    return SUCCESS;
  }
コード例 #2
0
  public void execute() throws Exception {
    InformationContainer infoContainer = new InformationContainer();
    MessageContainer msgContainer = new MessageContainer();

    for (CodeGenerator g : generators) {
      g.init();
      g.printUsage();
      g.inputInformation(infoContainer);
      g.execute(infoContainer, msgContainer);
    }

    System.out.println();
    System.out.println();
    System.out.println();
    if (Detect.notEmpty(msgContainer.getMessages())) {
      for (String str : msgContainer.getMessages()) {
        System.out.println(str);
      }
    }
  }