/**
* get file properties
* 获取文件的信息
* @author Mike
*
*/
public class FileOperation {
/**
* get file size 通过URL地址获取文件大小
* @param filePath * url file path
* @return filesize
* @throws MalformedURLException
*/
public static String getFileSize(String filePath) throws MalformedURLException{
HttpURLConnection urlcon = null;
String size="";
//format double
fnum = new ("#0.000");
//create url link
URL url=new URL(filePath);
try {
//open url
urlcon = (HttpURLConnection)();
//get url properties
double filesize=();
//format output
size=(filesize/1024);
} catch (IOException e) {
();
} finally{
//close connect
();
}
return size;
}
相关文章
- springboot获取配置文件中的值
- 通过URL获取文件的大小
- 根据路径或url获取文件名和文件大小
- 根据文件下载链接地址获取文件的大小
- 将Excel中的图片URL地址转成图片文件
- 通过springboot中ResponseBodyAdvice接口拦截URL以及返回data的拦截
- java中通过request获取路径中的不同信息
- Spring的配置文件,如何配置端口号,,properties,yml获取配置项等方法,外观模式及其优缺点,日志代表的信息
- idea 转换大小写在IntelliJ IDEA中,转换文本的大小写可以通过以下方法实现:使用快捷键Ctrl+Shift+U
- 通过sftp操作Linux服务器上的文件(java)