@Test public void testPing() throws IOException { byte[] bytes = Files.toByteArray(new File(getClass().getResource("/ping.bin").getFile())); Map<String,Object> map = Utils.deBencode(bytes); System.out.println(); }
public static Map<String, Object> deBencode(byte[] data) throws IOException { ByteArrayInputStream in = new ByteArrayInputStream(data); BencodeInputStream bencode = new BencodeInputStream(in); Type type = bencode.nextType(); try { Map<String, Object> dict = bencode.readDictionary(); return dict; } catch (Exception e) { return new HashMap<>(); } }
Utils { public static Map<String, Object> deBencode(byte[] data) throws IOException { ByteArrayInputStream in = new ByteArrayInputStream(data); BencodeInputStream bencode = new BencodeInputStream(in); Type type = bencode.nextType(); try { Map<String, Object> dict = bencode.readDictionary(); return dict; } catch (Exception e) { return new HashMap<>(); } } }
Utils { public static Map<String, Object> deBencode(byte[] data) throws IOException { ByteArrayInputStream in = new ByteArrayInputStream(data); BencodeInputStream bencode = new BencodeInputStream(in); Type type = bencode.nextType(); try { Map<String, Object> dict = bencode.readDictionary(); return dict; } catch (Exception e) { return new HashMap<>(); } }  }
Utils { public static Map<String, Object> deBencode(byte[] data) throws IOException { ByteArrayInputStream in = new ByteArrayInputStream(data); BencodeInputStream bencode = new BencodeInputStream(in); Type type = bencode.nextType(); try { Map<String, Object> dict = bencode.readDictionary(); return dict; } catch (Exception e) { return new HashMap<>(); } }  static String getNeighbour(String s1, String s2); static String randomId(); static String getRandomString(int size); static byte[] enBencode(Map<String, Object> map); static Map<String, Object> deBencode(byte[] data); static List<Node> decodeNodes(String encodeNodes); static byte[] getByteArray(byte[] bytes, int start, int end); static int getPort(byte[] bytes); }
Utils { public static Map<String, Object> deBencode(byte[] data) throws IOException { ByteArrayInputStream in = new ByteArrayInputStream(data); BencodeInputStream bencode = new BencodeInputStream(in); Type type = bencode.nextType(); try { Map<String, Object> dict = bencode.readDictionary(); return dict; } catch (Exception e) { return new HashMap<>(); } }  static String getNeighbour(String s1, String s2); static String randomId(); static String getRandomString(int size); static byte[] enBencode(Map<String, Object> map); static Map<String, Object> deBencode(byte[] data); static List<Node> decodeNodes(String encodeNodes); static byte[] getByteArray(byte[] bytes, int start, int end); static int getPort(byte[] bytes); static List<Node> fixedNodes; }