通过网络路径,返回输入流工具类
public static byte[] getUrlData(String urlPath) throws Exception{ URL url; byte[] data = null; InputStream input=null; try { url = new URL(urlPath); HttpURLConnection conn=(HttpURLConnection) url.openConnection(); conn.setConnectTimeout(5*1000); conn.setRequestMethod("GET"); int a=conn.getResponseCode(); if( 200==conn.getResponseCode()){ //判断是否连接成功 发送数据 input=conn.getInputStream(); //获得输入流 } } catch (MalformedURLException e) { e.printStackTrace(); } return input; }