How can I get the size of a file

I want the size by BYTE.

[url http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html#length()]File.length()

Similar Messages

  • How can I get the size of a file with apple script

    I try to get the size of a file within an apple script. But I did not find information how to do this.

    There are two ways. I think Apple is moving toward using System Events, which is listed first.tell application "Finder"
    set myFile to selection as alias
    --this just gets a file for me to work with
    --coercing it into an alias is required for the other functions
    end tell
    tell application "System Events"
    get size of myFile
    end tell
    set myInfo to (info for myFile)
    get size of myInfo

  • How can i change the size of PDF files ?

    how can i change the size of PDF files? when i convert documents in the acrobat browser it seems the files become larger then normal pdf files, this is, i compare with other files that people send to me and i realise that they are smaller than my converted files, even if they have more pages.

    A lot depends on the form of the PDF. Is it graphics, a scan of a text file, pure text, or other? What version of Acrobat are you working with.
    You can do a save as to get a WORD file, but do not expect great results. The ability to get a decent WORD file depends on what the form of PDF you are working from. If it was created from WORD with tags and all, you might get good results. If not, you might get a lot of messed up results.
    Explain what you are starting with and your ultimate goal. Also check the audit of the file (should be under PDF Optimize) to see where the file information is concentrated (text, fonts, graphics, other).

  • How can u get the Length of a file u are going to download?

    HI,<br>
    I have another question, is it possible that u can get the length of a file which u are just going to download?<br>
    <br>
    I have the following code example:<br>
    <br>url = new URL(dlfrom);<br>
    f=new File(url.toURI());<br>
    System.out.println(f.length)();<br><br>
    unfortunatly it keeps throwing an exception, please help.

    RTFM
    http://java.sun.com/j2se/1.5.0/docs/api/java/net/URLCo
    nnection.html#getContentLength()<br>
    I tried to apply your sollution, but it is allways returning -1, so what should I do now, is there any possebility still to get the length of the object, because i thought of doing something similar as a tool to download stuff

  • How can I get the size of all lines or the last line number in a DB?

    I want to display a certain number of lines from a DB.
    But before I fetch them out, I must know how many lines of this DB has.
    I donnot know if there is some methods have this function. I know the last() method can move the cursor to the last line, but some DB cannot support this function.
    Could someone know the answer or some examples about displaying data in a jsp?
    Thanks a lot.

    To get the number of rows in a ResultSet, loop over the result set with while(res.next()). Read each row into an object. Add each object into a, say, LinkedList. At the end, you will have the rows nicely converted to objects (which you probably should do anyway), and list.size() will give the number of objects.
    There are other ways to get the number of objects, but list.size() is the easy and reliable way. If you don't need the rows converted to objects ...why did you select them in the first place?
    Tricks with last() and whatnot sort of work. They read the entire result set into memory. But you'll need to write the while(res.next()) loop anyway. No point in having the computer do the same thing twice.

  • How can I get the size of conatiner which is kept in the array of conatiner?

    I have created an Array of Conatiner in Local variable (say Locals.Array_C). Within Array_C, I have few containers like Cont_1, Cont_2, Cont_3.
    Lets consider that there are four(4) Number fields added in the Cont_2.
    Here the number of elements in the Cont_2 is 4, but if I want to read this size through TestStand, how can I do that?
    I also tried to use "Call PropertyObject.GetNumElements" ActiveX property, but I could not get how to set Object Refernce in this case.
    Please help.
    Solved!
    Go to Solution.
    Attachments:
    Locals.Array_C.JPG ‏67 KB

    Hi,
    Your problem is how you are specify the array part. It may also be what you are using as the reference.
    Lets look ate the array part using the SequenceContext as the reference. The lookup string will be:
    "Locals.Array_C[1].Cont_2.Elemen4"
    If you are using the Locals as the reference the lookup string will be:
    "Array_C[1].Cont_2.Element4"
    Hope this helps
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • How do I get the size of a file on a server with an Applet

    Hei,
    I have a problem. I have some files that I need to read in with InputStream to get an Array of bytes. The Applet and the files are on the same server.
    My Prob is, that when I use
    URL(daFile).getFile().getSize();
    it only gives the inaccurate size from the dirlisting (i.e. 48 for 48k)
    So I can not build an array with the correct Size.
    Does anyone knows how I get the correct size of a file.
    Big thx
    LoCal

    Appler can open connections to server it was downloaded from. You don't need such complicated API as RMI... Just simple java server listening for queries.
    Like this:
    Applet:
    1. take a file path
    2. connect to simple server (gives OutputStream and InputStream)
    3. create ObjectOutputStream and send fiel to server (File is serializable)
    4. Read String with size from input stream
    Server
    1. Wait for connection
    2. When client connected create ObjectInputStream and expect File instance
    3. Get file size
    4 Replay with String with size
    Like this...

  • How can I limit the size of a file generated by 3rd party code?

    I have a program that loads plugins from a directory and executes code in those plugins. These plugins are classes that implement a standard interface within my API. I want to be able to monitor for files generated by these plugins. Usually there are no more than 2 plugins running at once, so I could end up with 2 plugins writing files. An example would be a plugin creating an SQLite database on the filesystem.
    I could monitor the current directory and guess who's file it is, but what if the files get written elsewhere? Can I do something in Java that limits what directories the Java process can write to?
    I wouldn't mind being able to track their memory and CPU usage, but I don't think I can do much about that.

    Thank you. I just needed to be pointed in the right direction. After looking over this stuff, including FilePermission, I think this may give me what I was looking for. It will be a while before I get to implementing it or testing something like this, I'm just trying to get a grasp on all of the things I need to do and how to approach it.
    By doing this I can control how much filespace it can use.
    I can control CPU usage by monitoring for extra threads that don't belong and killing or settings the priority on it.
    Now I just need to think of something to monitor how much memory the plugin uses. I suppose I could gc, then store the current memory usage, then execute the plugin, gc again, and measure the size again. Does that sound like a reasonable way to estimate it's memory usage? I'm not looking for tiny changes, I just want to see large, substantial increases.

  • How can I limit the size of a file upload?

    I am uploading a file using a file reference using the code below.  I want to  limit the file size (bytes) of the uploaded file to 100k, so that a huge file won't crash the browser or my SWF.
    What's the best place in the following process to test this, and actually prevent the large file from being loaded?  Is that even possible?
    private function uploadImageBtn_clickHandler() : void {
         var arr:Array = [];
         arr.push(new FileFilter("Images", "*.gif;*.jpeg;*.jpg;*.png"));
         fileRef.browse(arr);
    private function fileReference_select(evt:Event):void {
         fileRef.load();
    private function fileReference_complete(event:Event):void {
         var loader:Loader = new Loader();
         loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loader_complete);
         loader.loadBytes(fileRef.data);
    public function loader_complete (event:Event) : void {
         trace("Loader info = "+event.currentTarget.bytesLoaded); // file size in bytes
         var sourceBMP:Bitmap = event.currentTarget.loader.content as Bitmap;
         bgImage.source = sourceBMP; 

    Thank you. I just needed to be pointed in the right direction. After looking over this stuff, including FilePermission, I think this may give me what I was looking for. It will be a while before I get to implementing it or testing something like this, I'm just trying to get a grasp on all of the things I need to do and how to approach it.
    By doing this I can control how much filespace it can use.
    I can control CPU usage by monitoring for extra threads that don't belong and killing or settings the priority on it.
    Now I just need to think of something to monitor how much memory the plugin uses. I suppose I could gc, then store the current memory usage, then execute the plugin, gc again, and measure the size again. Does that sound like a reasonable way to estimate it's memory usage? I'm not looking for tiny changes, I just want to see large, substantial increases.

  • How can i get the directory of some files?

    I have the following class and the directory images in the same folder as this class. the problem is that i don't see the icons and i don't know how it works.
    please help. thanx a lot
    public class MyIcons {
    private final static String images = "images/";
    private final static String directory = getDirectory();
    public final static ImageIcon SAVE_FILE =
    new ImageIcon(directory + "savefile.gif");
    // not sure how to get the directory
    public static String getDirectory() {
    return ?????;
    }

    Try following code:
    import java.net.URL;
    public class MyIcons {
    private static final String images = "images/";
    private ImageIcon saveFile;
    public static void loadImage(){
    URL resourceURL = null;
    resourceURL = this.getClass().getResource(images
    + "savefile.gif");
    saveFile = new ImageIcon(resourceURL);
    }

  • How can I get the open counts on file type items?

    One of the managers' point of interesting on Portal usage is to know how frequently items are opened to view.
    I need to preapre a report to show managers which items (file type) are opened most frequently? and who opened the item most?
    How can I do it?
    Thanks,

    The Apple Support Communities are an international user to user technical support forum. As a man from Mexico, Spanish is my native tongue. I do not speak English very well, however, I do write in English with the aid of the Mac OS X spelling and grammar checks. I also live in a culture perhaps very very different from your own. When offering advice in the ASC, my comments are not meant to be anything more than helpful and certainly not to be taken as insults.
    Are you saying that you bought a used or second hand Mac? In North America an open box Mac usually refers to a display model used in a store.
    There is mixed info on this issue. Some folks in the US have called Apple Care and requested that the iLife apps prebundled with this specific Mac be released from original owner's Apple ID so the new owner can Accept the apps into their Apple ID, with success. Folks in Europe report that when making the same request of Apple Care they are met with resistance and are unsuccessful.
    YMMV
    The sad thing is that if Apple Care will not release the apps, then the owner of a second hand Mac cannot even purchaase the apps on their Mac! To buy the apps with their own account, they would need to find an older Mac running at least OS X Snow Leopard 10.6.8 with a Mac App Store (MAS), that also has never had the MAS versions of the iLife apps installed on it.

  • How to get the size of a file DONE

    How can I get the size a file? I want to do the following....
    File clobDataFile = new File("clob.dat");
    PrintWriter clobpw = new PrintWriter(new BufferedWriter(new FileWriter(clobDataFile)));
    int               offset     = //get the number of chars in the fileOk I am a tard... figured it out...
    File clobDataFile = new File("clob.dat");
    PrintWriter clobpw = new PrintWriter(new BufferedWriter(new FileWriter(clobDataFile)));
    int               offset     =colbDataFile.length();

    read API http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html#length()
    next time you have a similar question please refer this document

  • How can I reduce the size of stardard css and js of BSP?

    Hi all,
    I have problem with the js and css standard of sap.
    When I enter the first each in the portal, this css are loaded (after cache):
         - sapUrMapi_ie6.js with 333331 bytes
         - ur_ie6.css with 174256 bytes
         - popup_ie6.js with 22690 bytes
         - events.js 22886 bytes
    Total: more of less 1MB of datas.
    How can I reduce the size of these files?
    Can i not use this files and see the tabscripts or others object htmlb?
    thanks

    Hi Benito,
    these files contain all "stuff" that the BSP Extensions need to work. If you decide to code your own HTML content you don't need them.
    The other thing to consider is that these files should really be cached b your browser so this overhead only happens once.
    Cheers
    Graham

  • How can I get the edited pictures from the thumbnails to full size?

    I upgraded to iPhoto 11, the thumbnail photos show my previous edits, but when I click on the photo to make it bigger, it reverts back to the unedited, original picture.  How can I get the edited pictures from the thumbnails to full size?

    Verify you are using iPhoto11 ver 9.5
    if not run the >Software update or check your apps folder and make sure the correct iPhoto is launched,  not an older ver.

  • How can I get the "Open" and "Save As" dialog boxes to open at larger than their default size?

    How can I get the "Open" and "Save As" dialog boxes to open at larger than their default size?  I would like them to open at the size they were previously resized like they used to in previous operating systems.  They currently open at a very small size and the first colum is only a few letters wide necessitating a resize practically every time one wants to use it.  Any help would be appreciated.

    hi Prasanth,
    select werks matnr from ZVSCHDRUN into table it_plant.
    sort it_plant by matnr werks.
    select
            vbeln
            posnr
            matnr
            werks
            erdat
            kbmeng
            vrkme
            from vbap
            into table it_vbap
            for all entries in it_plant
            where matnr = it_plant-matnr and
                  werks = it_plant-werks.
    and again i have to write one more select query for vbup.
    am i right?

Maybe you are looking for

  • Can I add a second activity indicator? (Or more)

    I have Firefox 4.0.1 Just wanted to know if it's possible to add a second activity indicator or more.

  • Where are the Theme Images

    Hi, I am using the Watercolour these at the moment, but want to change the colours of the images - is there an easy way to do this? Where are the image files located? Thanks Rich

  • Error During creation of Items

    guruz, we are working on Item Conversion. While creating an item,we'r constantly getting following error from last couple of days,where ERROR MESSAGE is not given [?] :( How shall we trace the error? TRANSACTION ID : 620756 ORGANIZATION ID : 204 TABL

  • Upgraded my iPhone 4 to os7 where is my verification code

    Upgraded my iPhone 4 to os7 do I need a verification code

  • Adobe reader 8 / acrobat

    I have windows xp. I am trying to open a pdf file that was sent to me. I have adobe reader 8. I was told by my instructor I need acrobat to open it. Doesn't adober reader 8 have acrobat or do I need something else? I am Computer DUMB!! Please help me