Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Parser
- {
- public static void prepareJars()
- {
- try
- {
- URL xmlURL = new URL("http://minesquid.fr/Launcher/bin.xml");
- InputStream xml = xmlURL.openStream();
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- DocumentBuilder db = dbf.newDocumentBuilder();
- Document doc = db.parse(xml);
- Node node = doc.getFirstChild();
- for (int i = 0; i < node.getChildNodes().getLength(); i++)
- {
- Node parse = node.getChildNodes().item(i);
- if (parse.getNodeName().equals("Contents"))
- {
- String key = parse.getChildNodes().item(1).getTextContent();
- String md5 = parse.getChildNodes().item(3).getTextContent().replace("\"", "");
- double size = Double.parseDouble(parse.getChildNodes().item(5).getTextContent());
- File local = new File(Util.getWorkingDirectory(), key);
- if (!local.isDirectory())
- {
- boolean correct = true;
- if ((!local.exists()) || (!md5.equals(Hasheur.getMD5(local)))) {
- correct = false;
- }
- if (!correct) {
- System.out.println(local.getName() + " : " + correct + " : " + size + " : " + local.getAbsolutePath());
- }
- Updater.files.put(key, new Fichier(size, "http://minesquid.fr/Launcher" + key, local.getAbsolutePath(), correct));
- }
- }
- }
- xml.close();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- public static void prepareRessources()
- {
- try
- {
- URL xmlURL = new URL("http://minesquid.fr/Launcher/res.xml");
- InputStream xml = xmlURL.openStream();
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- DocumentBuilder db = dbf.newDocumentBuilder();
- Document doc = db.parse(xml);
- Node node = doc.getFirstChild();
- System.out.println("------------------ node lenght : " + node.getChildNodes().getLength());
- for (int i = 0; i < node.getChildNodes().getLength(); i++)
- {
- Node parse = node.getChildNodes().item(i);
- if (parse.getNodeName().equals("Contents"))
- {
- String key = parse.getChildNodes().item(1).getTextContent();
- String md5 = parse.getChildNodes().item(3).getTextContent().replace("\"", "");
- double size = Double.parseDouble(parse.getChildNodes().item(5).getTextContent());
- File local = new File(Util.getWorkingDirectory(), key);
- boolean correct = true;
- if ((!local.exists()) || (!md5.equals(Hasheur.getMD5(local)))) {
- correct = false;
- }
- if (!correct) {
- System.out.println(local.getName() + " : " + correct + " : " + size + " : " + local.getAbsolutePath());
- }
- Updater.files.put(key, new Fichier(size, "http://minesquid.fr/Launcher" + key, local.getAbsolutePath(), correct));
- }
- }
- xml.close();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement