public static byte[] urlTobyte(String url) throws MalformedURLException {  
    URL ur = new URL(url);
    BufferedInputStream in = null;  
    ByteArrayOutputStream out = null;  
    try {  
        in = new BufferedInputStream(ur.openStream());  
        out = new ByteArrayOutputStream(1024);  
        byte[] temp = new byte[1024];  
        int size = 0;  
        while ((size = in.read(temp)) != -1) {  
            out.write(temp, 0, size);  
        }  
    } catch (Exception e) {  
        e.printStackTrace();  
    } finally {  
        try {  
            in.close();  
        } catch (IOException e) {  
            e.printStackTrace();  
        }  
    }  
    byte[] content = out.toByteArray();  
    return content;  
} 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
  • 2021-12-09
  • 2021-11-05
  • 2022-12-23
猜你喜欢
  • 2022-01-20
  • 2021-05-12
  • 2021-09-09
  • 2022-12-23
  • 2021-07-14
  • 2022-12-23
  • 2021-10-15
相关资源
相似解决方案