远程url文件地址转成byte
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; }