예제 #1
0
 public void sendUpdate() throws Exception {
   Socket socket = new Socket(hcs.getAddress(), hcs.getPort());
   BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
   writer.write("<ppEngineUpdated>\n");
   writer.flush();
   Logger.log("Sent <ppEngineUpdated> to " + hcs.getLabel());
   writer.close();
   socket.close();
 }
예제 #2
0
  public void connectFtp() throws Exception {
    ftp.setDefaultTimeout(1500);
    ftp.connect(hcs.getAddress());
    ftp.login(hcs.getUsername(), hcs.getPassword());
    int reply = ftp.getReplyCode();

    if (FTPReply.isPositiveCompletion(reply)) {
      System.out.println("HCS " + hcs.getLabel() + ": Connected successfully");
    } else {
      System.out.println("HCS " + hcs.getLabel() + ": Connection failed");
      ftp.disconnect();
    }
  }
예제 #3
0
  public void uploadFile(String name, InputStream input) throws Exception {
    ftp.enterLocalPassiveMode();

    ftp.changeWorkingDirectory(DEFAULT_WORKING_DIR);
    Logger.log("HCS " + hcs.getLabel() + ": Current directory is " + ftp.printWorkingDirectory());

    ftp.enterLocalPassiveMode();

    ftp.storeFile(name, input);
    ftp.logout();
    ftp.disconnect();

    Logger.log("HCS " + hcs.getLabel() + ": Upload of ppEngine.dat complete!");
  }