lengthpublic long length()Returns the length of the file denoted by this abstract pathname. The return value is unspecified if this pathname denotes a directory.
Returns:
The length, in bytes, of the file denoted by this abstract pathname, or 0L if the file does not exist
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkRead(java.lang.String) method denies read access to the fileeg:File file = new File(filepathname);
   long len =  file.length()

解决方案 »

  1.   

    File file = new File("c:/test.txt");
    System.out.println(file.length());
      

  2.   

    String homepagepath="D:/java/temp.txt";
    File file1=new File(homepagepath);
    System.out.println(file1.length());
    -----------
    Class File -lengthpublic long length()
    Returns the length of the file denoted by this abstract pathname.Returns:The length, in bytes, of the file denoted by this abstract pathname, or 0L if the file does not existThrows:SecurityException - If a security manager exists and its SecurityManager.checkRead(java.io.FileDescriptor) method denies read access to the file
      

  3.   

    File file = new File(yourFileName);
    long length = file.length();
      

  4.   

    file.length()返回值不是file组件所代表的路径的长度吗?
      

  5.   

    The length, in bytes, of the file denoted by this abstract pathname, or 0L if the file does not exist
    当前路径名所指向的文件的字节数 或者为0改文件不存在