Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: files size for files inside the JAR file

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default files size for files inside the JAR file

    Hey all!

    first off I apologize if i might have posted this in the wrong category of the forum, I was a little unsure if to post it here or in the File I/O part.

    anyways on to my problem:

    I have a program with some files packed with it (they are contained inside the JAR file when compiled) and i need to be able to grab their filesize and the best way to do that would be to use the File class but I cant seem to get the path to the files correct since they are "baked" into the JAR file. Is there another smarter way to get filesize of a file then the File class with the method file.length(); when files are meant to be "baked" into the JAR file?

    not asking to fix my code per say (thats why im posting in general) since I want to know for later if I make other programs and run into the same issue again

    //your sincerely Natherul


  2. #2
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: files size for files inside the JAR file

    getSize()/getCompressedSize() provide two metrics for the size of a zip entry. (jar files are a sort of zip file, and are made up of a number of entries which when unzipped become files)

  3. The Following User Says Thank You to pbrockway2 For This Useful Post:

    Natherul (February 9th, 2012)

  4. #3
    Junior Member
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: files size for files inside the JAR file

    thank you, I will try them out tomorrow as its late now any chance of a really small example on how to use them properly?

  5. #4
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: files size for files inside the JAR file

    There is an example at java2s.com.

  6. The Following User Says Thank You to pbrockway2 For This Useful Post:

    Natherul (February 9th, 2012)

Similar Threads

  1. [SOLVED] How to move files from one directory to another considering its size
    By kewlkeny in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: January 20th, 2012, 06:37 AM
  2. Seraching through files in a folder for a pattern match inside the files.
    By dazzabiggs in forum What's Wrong With My Code?
    Replies: 4
    Last Post: May 2nd, 2011, 08:35 AM
  3. Not able to put some files inside Zip file
    By chinnu in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: March 23rd, 2011, 05:17 AM
  4. Replies: 1
    Last Post: March 22nd, 2011, 06:59 PM