Java tutorial
//package com.java2s; import java.io.File; public class Main { public static int getFileSize(String fileName) { File f = new File(fileName); long len = f.length(); len = len > Integer.MAX_VALUE ? Integer.MAX_VALUE : len; return (int) len; } }