JAVA获取远程文件

//path,如:http://xxxx/a.flv
public boolean getExistsUrl(String path){
    try {
        URL url = new URL(path);
        HttpURLConnection httpURLConnection = null;
        httpURLConnection = (HttpURLConnection) url.openConnection();
        Long size=Long.parseLong(httpURLConnection.getHeaderField("Content-Length"));
        if (size>3000){
            System.out.println("存在");
            return true;
        }
       //其它不细写了,
//httpURLConnection从这个对象中可以获取很多东西了
 } 
  catch (Exception e) { e.printStackTrace(); } 
  return false;} 
  
 
  
 
 

你可能感兴趣的:(其他)