- 354 名前:310 mailto:sage [2007/07/15(日) 21:46:05 ]
- // 接続先のファイルサイズを取得
public long getFileSize(String cnurl) { boolean isCnct = cnct(cnurl) ; // ※接続テストをしているらしい if (!isCnct) { return -1; } // 接続可能ならtrue URL url; try { url = new URL(cnurl); HttpURLConnection urlconn; urlconn = (HttpURLConnection)url.openConnection(); long fullsize = 0; Map headers = urlconn.getHeaderFields(); String key = "Content-Length" ; String e = (headers.get(key)).toString(); e = e.substring(1,e.length()-1) ; fullsize = Long.parseLong(e) ; boolean isDisCnct = discnct(cnurl) ; // ※ここで310呼び出し if (!isDisCnct) { return -1 ; } if(fullsize < 0) return -1 ; else return fullsize ; } catch (IOException e1) { } return 0; }
|

|