Example usage for java.io File length

List of usage examples for java.io File length

Introduction

In this page you can find the example usage for java.io File length.

Prototype

public long length() 

Source Link

Document

Returns the length of the file denoted by this abstract pathname.

Usage

From source file:Main.java

public static boolean fileSizeExceedCheck(File file, long j) {
    return file.length() / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID < j;
}

From source file:Main.java

public static long getFileSize(String path) {
    File file = new File(path);
    return file.length();
}

From source file:Main.java

public static byte[] LoadImage(String filePath) throws Exception {
      File file = new File(filePath);
      int size = (int) file.length();
      byte[] buffer = new byte[size];
      FileInputStream in = new FileInputStream(file);
      in.read(buffer);//from w  ww.ja va 2 s  .co  m
      in.close();
      return buffer;
  }

From source file:Main.java

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;
}

From source file:Main.java

public static long getFileSize(File fn) {
    return fn == null ? 0 : fn.length();
}

From source file:Main.java

public static int getBlockNum(File file, int blockSize) {
    return (int) Math.ceil(file.length() / (double) blockSize);
}

From source file:Main.java

public static long setFileSize(String path) {
    File f = new File(path);
    return f.length();
}

From source file:Main.java

public static long doCalcularTamanhoDiretorio(File dir) {
    long tamanho = 0;
    for (File f : dir.listFiles()) {
        tamanho += f.length();
    }//from ww  w  .  j av a  2s  .c o  m

    return tamanho;
}

From source file:Main.java

public static long getKB(File file) {
    return getKB(file.length());
}

From source file:com.sm.store.TestPhp.java

public static byte[] readFile(String filename) throws IOException {
    File file = new File(filename);
    long size = file.length();
    byte[] data = new byte[(int) size];
    FileInputStream fip = new FileInputStream(file);
    int len = fip.read(data);
    if (len != data.length)
        throw new RuntimeException("size expect " + data.length + " get " + len);
    else//from   w ww  .j a v  a 2s . c o  m
        return data;
}