| | |
| | | private String path = "/"; |
| | | |
| | | @RequestMapping(value = "/index", method = RequestMethod.GET) |
| | | public Version index() throws Exception { |
| | | FTPClient ftpClient = new FTPClient(); |
| | | ftpClient.connect(ip, port); |
| | | ftpClient.login(userName, userPwd); |
| | | if (path != null && path.length() > 0) { |
| | | ftpClient.changeWorkingDirectory(path); |
| | | } |
| | | String content = readFile(ftpClient); |
| | | if(ftpClient.isConnected()) { |
| | | ftpClient.logout(); |
| | | ftpClient.disconnect(); |
| | | } |
| | | SAXReader reader = new SAXReader(); |
| | | Document document = reader.read(new InputSource(new ByteArrayInputStream(content.getBytes("utf-8")))); |
| | | Element root = document.getRootElement(); |
| | | public Version index() { |
| | | Version version = new Version(); |
| | | version.setVer(root.element("Ver").getText()); |
| | | version.setFileName(root.element("FileName").getText()); |
| | | version.setFileMD5Hash(root.element("FileMD5Hash").getText()); |
| | | |
| | | FTPClient ftpClient = new FTPClient(); |
| | | try { |
| | | ftpClient.connect(ip, port); |
| | | ftpClient.login(userName, userPwd); |
| | | if (path != null && path.length() > 0) { |
| | | ftpClient.changeWorkingDirectory(path); |
| | | } |
| | | String content = readFile(ftpClient); |
| | | if(ftpClient.isConnected()) { |
| | | ftpClient.logout(); |
| | | ftpClient.disconnect(); |
| | | } |
| | | SAXReader reader = new SAXReader(); |
| | | Document document = reader.read(new InputSource(new ByteArrayInputStream(content.getBytes("utf-8")))); |
| | | Element root = document.getRootElement(); |
| | | version.setVer(root.element("Ver").getText()); |
| | | version.setFileName(root.element("FileName").getText()); |
| | | version.setFileMD5Hash(root.element("FileMD5Hash").getText()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // version.setVer("a"); |
| | | // version.setFileName("b"); |
| | | // version.setFileMD5Hash("c"); |