How to know the size of a file in a program ?

I am compiling a program and I have to use a function in Java to know the size of some files. How can I do? Thanks

File.length() not good enough?

Similar Messages

  • How to know the size in byte of a file before importing it with ftp

    hello
    i have a file in witch there is the pathe of many file
    i reade these path and i use ftp to get these file
    my problem is that i want to display a progress bar during the getting of file
    so dont no how i can know the size of these file to put a maximum to the progress bar

    package cni;
    import javax.swing.*;
    import sun.net.ftp.*;
    import sun.net.ftp.FtpClient.*;
    import java.io.*;
    import java.lang.*;
    import sun.net.TelnetInputStream;
    import java.util.*;
    import java.lang.String;
    public class FTPclients
    //Variables
    private static String server = "faycal";
    private static int port = 21;
    private static String user = "anonymous";
    private static String passwd = "[email protected]";
    public String toString(JTextField tx)
    String txt;
    txt= new String(tx.getText());
    return txt;
    public static void main(String args[])
    ConnFile cf = new ConnFile("d:\\cni\\adresse.txt");
    FTPclients fc = new FTPclients();
    ConnFile cfbis = new ConnFile("d:\\cni\\chemin.txt");
    try
    //String s=cf.lectureid();
    String s;
    while((s=cf.br.readLine())!=null)
    String s1=s.substring(0,s.lastIndexOf("\\"));
    String s2=s.substring(s.lastIndexOf("\\")+1);
    System.out.println(s1);
    System.out.println(s2);
    //ajout du double anti slash a la chaine s1
    String name =s1;
    StringBuffer sb = new StringBuffer(s1.length()+10);
    for(int index=0; index<s1.length();index++)
    char c = s1.charAt(index);
    sb.append(c);
    if(c=='\\')
    sb.append('\\');
    System.out.println(s1);
    s1= sb.toString();
    System.out.println(s1);
    //creation d un client ftp
    FtpClient client = new FtpClient();
    System.out.println("gggggggggggggalut");
    client.openServer(server,port);
    System.out.println("xxxxxxxxxxxxalut");
    client.login(user, passwd);
    client.binary();
    client.cd(s1);
    System.out.println("la taille de "+s1+" est "+taille+" octets");
    System.out.println("ssssssssssssalut");
    System.out.println(client.welcomeMsg);
    System.out.println("buhhhhhhhhhhhhh");
    //copie du chemin saisi par l utilisateur
    String chemre;
    cfbis = new ConnFile("d:\\cni\\chemin.txt");
    String chemvir = cfbis.lectureid();
    System.out.println(chemvir);
    if (chemvir==null)
    chemre="d:\\";
    System.out.println(chemre);
    else
    chemre=chemvir;
    System.out.println(chemre);
    String chem=chemre+"\\"+s2;
    System.out.println(chem);
    //pour creer le nouveau fichier
    TelnetInputStream fich = client.get(s2);
    FileOutputStream out = new FileOutputStream(chem);
    //pour ecrire dans le nouveau fichier
    int i;
    while(true)
    i = fich.read();
    if(i == -1)
    { break; }
    out.write((byte)i);
    System.out.println("bahhhhhhhhhhhh");
    //fermeture du serveur ftp
    client.closeServer();
    System.out.println("ok");
    }//fin while
    String chemvir = cfbis.lectureid();
    }//fin du try
    catch(IOException e)
    System.out.println(e);
    }//fin du main
    }// fin de la classe
    do you know how

  • How do I know the size of a file

    Hi,
    Would anybody please show me how to get the size of a file. for example, I create a file like this
    FileInputStream FINPUT = new FileInputStream ("c:\\testing.prn");
    I need to know the size of FINPUT before using it but I don't know how.
    note: It is not neccessary to use FileInputStream. I can use any stream or file that allow me to check the size and read out the data from the file byte by byte.
    Thanks a lot.
    Hung

    Thank you for your responding. But, how can I read out the data? I need to read the data from the file byte by byte.
    Thanks
    Hung.

  • How to know the size of a DATABASE ?

    Guys,
    How to know the size of a DB ?
    Also
    How to know the size of a TABLE ?
    How to get the content of a procedure/view/trigger ?
    Inputs are welcome !

    How to know the size of a DB ?If you want to know the physical size, query dba_data_files + dba_temp_files. if you need to know the actual consumed space in those files, compute sum of bytes from DBA_SEGMENTS.
    How to know the size of a TABLE ?Query all/dba/user_segments.
    How to get the content of a procedure/view/trigger ?all/dba/user_source, all/dba/user_views, all/dba/user_triggers.
    Message was edited by:
    Satish Kandi

  • How to know the size of a webservice request

    Hello...
    I'd like to know if you know how do I get the size of a Web request? I mean, I need to know the size of a Web Request 'cause I'll fill a Gauge Object up based on the quantity that I have received from the WebService.
    I'm using the KSOAP and KXML API's for consuming that WebServices and I used the Content-lengh Method and it didnt return anything to me... it returned empty. So, do you know how do I fill a Gauge Object based on the size of the WebRequest? Could you tell me some examples plz?
    Thanx...
    Lucas Abrao

    How to know the size of a DB ?If you want to know the physical size, query dba_data_files + dba_temp_files. if you need to know the actual consumed space in those files, compute sum of bytes from DBA_SEGMENTS.
    How to know the size of a TABLE ?Query all/dba/user_segments.
    How to get the content of a procedure/view/trigger ?all/dba/user_source, all/dba/user_views, all/dba/user_triggers.
    Message was edited by:
    Satish Kandi

  • How to determine the size of a file on application server

    Hello,
    using open dataset I have created a file on the application server and have put some data into the file.
    Now I want to know the size of this file.
    Is there a function module to do this ?
    Best regards
    Michael

    Hi,
    Use Function module   'EPS_GET_FILE_ATTRIBUTES'
    DATA fsize TYPE epsf-epsfilsiz.
    CALL FUNCTION 'EPS_GET_FILE_ATTRIBUTES'
      EXPORTING
        file_name =     " here provide filename
        dir_name  =    "  here provide directory
      IMPORTING
        file_size = fsize.
    WRITE: 'File size' , fsize.
    Regards,
    Ravi

  • How to know the size in bytes of a directory?

    I would like to know if there's a class or a function which allows to know the size of all files in a directory?

    You have to create a File object for your directory, then list all files (using the list() method) and create a File object for each item returned. Then ask each File object for it's size and add them up.
    Thomas

  • How to know the size of bad sector block after zero out erase?

    I found some problems on my USB external harddisk recently. After I backup all the files, I erased the whole volume by choosing "zero out data" option. According to some web articles, "zero out" detects and marks those bad sectors to avoid further read/write action on the damaged area.
    My question is that how can I know the size of disk space marked as bad sector? Because I can only see how many space is used or available when I check a disk in disk utility. There are about 600MB used for my 1TB hard drive. I guess there is some storage used by spotlight or other hidden files. But I have no idea for how many MB is occupied by bad sector...

    Yes you can look at see the original number of spares, the number used, and the number remaining spares.
    Disk Warrior for one, writes the SMART data to system.log Other programs can also read and report (not sure which if any write to system.log though) those field values from SMART table entries.
    IF the number of spares is declining, time to replace. Trouble is OS X hasn't had a good record of reporting I/O errors, let alone remapping. Some 3rd party utilities will. I've found the vendor (WD, Hitachi etc) have the best utility for their own drives, but those are Windows programs or LinuxCD. Also the best way to zero and map out bad sectors, too.

  • How to know the size of archived logs created under ASM

    I using Oracle 10g on Linux x86-64.
    I need to ship the archived logs(not the entire directory, only a few) from the Live database to the DR site, so I need an estimate of how much time it will take to ship them across the network ?
    Is there anyway I can know the size of a specific archived log file stored under ASM ?
    We can use du in ASM to know the size of directory but I dont find a command in ASM to get the size of a file ?

    No we are also switching logfiles manually , so the maximum size may not
    have reached.
    What I need is something like ls -l command in the Unix prompt which will
    help us to find the size of the file , a similar command to help us determine
    a size of file in ASM ?What is the objective?
    Anyways, you can get the size of an archived log file by quering V$ARCHIVED_LOG view.
    SQL> select sequence#, name, blocks*block_size from v$archived_log where sequence# > 180;
    SEQUENCE# NAME                                     BLOCKS*BLOCK_SIZE
           182 C:\MYDB\ARCH\ARC00182_0633314306.001             223053312
           181 C:\MYDB\ARCH\ARC00181_0633314306.001             264281600
           183 C:\MYDB\ARCH\ARC00183_0633314306.001              26209280
           184 C:\MYDB\ARCH\ARC00184_0633314306.001                  4096
           185 C:\MYDB\ARCH\ARC00185_0633314306.001                 16384
    SQL>

  • How to change the size of redo file

    Deal all,
    I finish installed the db,and the size of redo file is 50m by default. I found many "checkpoint not complete" events in alert.log file.
    Now i want to change it to 100M and try to avoid the event appear again ,how can i do?

    As Sb has already correct reply that size of redo logs can not be changed. We have to create new bigger/smaller size of redo logs and then 'alter system switch logfile' to inactivate older logs. Now you can drop older logs. Redo logs are something a glass of water. We can not change the size of glass, if we wish to dring more/less water, we will take that sized glass and we will get that sized water.
    Remember to consider the multiplexing/grouping when doing any maintenance like this. And there may be archive log & backup space considerations.
    Hans @ http://dbaspot.com/oracle-server/33231-changing-redo-log-file-size.html
    Regards
    Girish Sharma

  • How to know the size of the EEPROM after loading any Applet

    How can I know the size of the EEPROM after loading any applet..
    Any comments on this is appreciated
    Thank you in advance

    kishansaralaya wrote:
    Thanks for your suggestion.
    But when I try to use
    short memRemaining = JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_PERSISTENT);
    it always shows 32767. Even after loading some applet.
    And I am using 72K Java card then how it can show only 32Kbyte as the remaining memory value.This is because a short isn't big enough to display a number above 32767. One way around this is to use a byte[] to fill up some of the space with your temporary applet.
    byte[] memoryFiller = new byte[32767];
    short memRemaining = JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_PERSISTENT);The value of memRemaining + 32767 is the amount of persistent memory left on the card. If memRemaining is still 32767, you can add another byte[] starting with small values and increase the size until you get a meaning ful result (less than 32K).

  • How to know the size of data in some columns of a table?

    Hi,
    How can the size of of data for some specified column be determined?
    For example : TableA has 20 columns and the size of table is 20 GB. I want to know the size of data kept in last four columns.
    Thanks in Advance,
    Vishu

    You could use vsize to determine the size of a column element and sum them upselect sum(vsize(column_of_interest)) from whatever_table;

  • How to find the size of a file or folder

    How can I find the size of a file or folder?
    I am trying to determine the size of my iPhoto and Mail folder.
    It says "Size: --" under general from Get Info.

    It's working fine...
    When you ask for that info, and Finder presents those '--' dashes instead of a value, actually, Finder is calculating the value in background.
    That's something that i recently noticed and wonder why tha heck he needs to do all that work by himself, kinda re-inventing the wheel of file size value "calculus"...
    I posted some thoughts about it here: File / Folder size... How do Finder gets it?
    Will appreciate feedback about this!
    Props!

  • How to know the size of a message I wrote

    When I created a photojournal, with comments before each photo, I got a message "The size of the message you are trying to send exceeds the global size limit of the server."
    So it was not sent and I was told to reduce it and try again. I did that with the photos, deleted a few, as well, but still got the error message, and have not discovered how to find the size of the message.

    save it to drafts.
    in the drafts folder, click on the little table widget right on the right side of the column headings... select size
    Remember size increases about 30% for attachments.

  • How to know the size of the file

    hi all ,
    how can I know the file Size (like 23K, 45K, 0K)..
    if anyone knows please help me
    thanks

    Just use the length of the File class...

Maybe you are looking for

  • Error RSDMD 194 due to '#" after migration in BI 7

    Hi Gurus, we migrate our server BI in BI 7 and Unicode (from 3.5, non Unicode) and now on 0customer loading we have an error on a few lines RSDMD 194. it seems to be the character '#' is not accepted. in RSKC we have the customizing ALL_CAPITAL. this

  • Reservation of Stock for different business processes

    Hi We have a scenario  like two types of sales processes are there 1. Direct Sales 2. E-sales From Plant-A  both sales will happen, but while creating sales order for   direct sales 70% of the plant capacity  and E-sales 30% of the plant capacity. pl

  • Too scared to try.......

    I have a 30 gb iPod.  I've had it for years and love it! I have never downloaded anything from iTunes.  Every song that is on my iPod I physically had the CD at one point and time and ripped it to my library, then I would sync the ipod to the library

  • Display Dims before boot and after shutdown are complete

    This is probably a stupid question but a while back I clicked on an option to have my display dim during the shutdown process and stay dim until it was completely booted. I would like to turn this off but I can't find where the option was.  I've chec

  • Running change on prod ord. numbers

    Hi Experts, Could any of you pls help me to set substitutionals for production orders? I need to change number range on a prod order type, but as a running change: existing orders could not be closed u2013 long standing orders, duration more than 6 m