Java tutorial
//package com.java2s; import java.io.File; import java.io.FileInputStream; public class Main { private static long getFileSize(File file) throws Exception { long size = 0; if (file.exists()) { FileInputStream fis = null; fis = new FileInputStream(file); size = fis.available(); } else { file.createNewFile(); } return size; } }