Here you can find the source of getFileSize(final String filename)
Parameter | Description |
---|---|
filename | - file to size |
public static long getFileSize(final String filename)
//package com.java2s; /*/*from www . ja va 2 s .c o m*/ * Copyright (c) 2006 Stephan D. Cote' - All rights reserved. * * This program and the accompanying materials are made available under the * terms of the MIT License which accompanies this distribution, and is * available at http://creativecommons.org/licenses/MIT/ * * Contributors: * Stephan D. Cote * - Initial API and implementation */ import java.io.File; public class Main { /** * GetFileSize - returns the file size * * @param filename - file to size * * @return length of file */ public static long getFileSize(final String filename) { File f; try { f = new File(filename); if (f.exists()) { return f.length(); } } catch (final Exception e) { } return -1; } }