Size of a File object

Hi:
I would like to know generally how big is the size of your File object
Let us say I have a file called
c:/test.txt and the test.txt file itself is around 10K,
Then if i do something like
File file = new File("C:/test.txt");
I would assume the "file" object that is in virtual memory would be around 10K as well, I do understand that once this object is no loger referenced. it will be cleaned by the garbage collector,
So can someone enlighten me on this subject?
Thanks

You are wrong: a File object doesn't necessary point to a real file. You can have a file like C:\test.txt and not have a File object for it, or have a File object pointing to C:\test.txt, without the file C:\test.txt existing on your HDD. So the size of the File object has nothing to do with the real file.

Similar Messages

  • Using a File Object

    I have downloaded a file from a FTP site into a File object. This file doesn't actually exist the file itself is in memory. Instead of using the renameTo() command to save the file to the hard drive I want to take the file and get its contents and store it in a string object? Im imaging this is something like a FileStream object but im not sure. Here is a snippet that I shows I have successfully downloaded the file off the FTP site and I want to get its contents ands tore it in a string besides saving to a file. Below I am saving the file to a hard drive but I do not want to do this anymore.
    String currString = (String)fileListNames.get(c);
    currentFile = ftps.download(currString);          
    File dummy = new File(config.getConfig("billEDIDir") + currString);
    fileList[c] = config.getConfig("billEDIDir") + currString;
    if(dummy.exists())
         dummy.delete();
    currentFile.renameTo(dummy);
    Thanks for any help!

    Im creating a Java Service in the webMethods Intergration Tool. Here is the entire class.
    ****************************CODE************************************
    IDataCursor pipelineCursor = pipeline.getCursor();
    int count,currCount;
    String error = "";
    String status = "";
    Ftps ftps = null;
    File currentFile = null;
    Enumeration x;
    Enumeration y;
    ArrayList fileListNames = new ArrayList();
    try
         ftps = new Ftps("*******","********","*********");
         ftps.setDataPortRange(6100,6199);
         ftps.setPassive(true);
         ftps.connect();
         ftps.setBinary();
         ftps.setDir("outbound");
         ftps.setDir("KUED");
         count = 0;
         for (x = ftps.getNameListing(); x.hasMoreElements() ;)
              count++;
              x.nextElement();
         currCount = 0;
         for (y = ftps.getNameListing(); y.hasMoreElements() ;)
              currCount++;
              String m = (String)y.nextElement();
              fileListNames.add(currCount - 1,m.toString());     
         status = ftps.getDirListingAsString();
    catch(FtpException fexp)
         error = fexp.getMessage();
         throw new ServiceException( fexp.toString() );     
    catch(Exception e)
         error = e.getMessage();
         throw new ServiceException( e.toString() );     
    String [] fileList = new String[count];
    String [] fileContentList = new String[count];
    try
         for(int c=0;c<fileListNames.size();c++)
              String currString = (String)fileListNames.get(c);
              currentFile = ftps.download(currString);          
              File dummy = new File(config.getConfig("billEDIDir") + currString);
              fileList[c] = config.getConfig("billEDIDir") + currString;
              if(dummy.exists())
                   dummy.delete();
              currentFile.renameTo(dummy);
    //In this string list store the contents of each file downloaded.
              fileContentList[c] = "";
              ftps.disconnect();
    catch(Exception e)
         error = e.getMessage();
         throw new ServiceException( e.toString() );     
    IDataUtil.put( pipelineCursor, "status", status );
    IDataUtil.put( pipelineCursor, "error", error );
    IDataUtil.put( pipelineCursor, "fileList", fileList );
    IDataUtil.put( pipelineCursor, "fileContentList", fileContentList );
    pipelineCursor.destroy();
    ****************************CODE************************************

  • How to minimize the file size of a file with drawing markups

    Scenario:
    I need to turn a sample of a report into a report template, so I am deleting as many objects as I can with the Tools>Content>Edit Object.  For text that I cannot delete that way, I am covering it up with a white box (Comment>Drawing Markups>square and setting outline = white and fill = white).  On this particular PDF, there are about 20 of these white boxes.  I'm then using Preflight>Flatten annotations and form fields to flatten all of the markups.
    Problem:
    Unfortunately, even after using Preflight and Save As>Reduced Size PDF, the file size is still over 900 kb.  The original file size before I make any changes is less than 150 kb.  I need the final file size to be 200-300 kb.
    Settings:
    Windows 7
    Adobe Acrobat X Pro
    Solutions?
    I may be going about this all wrong, so any advice you have is much appreciated!  The only other thing I can think of to do (since I can't get a blank sample report), is to recreate the report in Word and then PDF it.  I'm hoping there's a better solution.  I tried Photoshop first and the file sizes were in the MBs, so I switched to Acrobat.  Maybe a different program would work even better?

    Basically that is what Bill is telling you. The best method is to:
    create the design of the form in Word.
    Save as a PDF (on a Mac the best method is to go to print menu click pdf and hold mouse or track pad button down, and Chose Adobe PDF) .
    Then open PDF in Acrobat
    Click on Tools
    Click on Forms and create form. Either letting acrobat create the fields and add or take away fields as need.  Or create fields manually.
    This way should you need to make correction you can open the original Word Document, Make chages save as PDF The in open original in PDF. Click on Tools > Pages and choose replace pages and replace desired page(s) as needed. Then readjust fields if needed or add or take fields as needed.

  • How to increase page size for balance file upload in Workspace.

    Hi All,
    Please suggest how to increase page size for balance file upload in shared Workspace pages.
    Thanks,

    A word of caution is in order regarding changing from facing to non-facing and back again. If you have overridden master page items, you'll get a second, non-overridden copy on all the even-number pages when that half of the master page is re-applied. This applies to master text frames which override automatically when text flows into them as well as to objects you manually override. I think you'll find this particular technique also only works for master text frames, whereas the Layout Adjustment should work in all situations where frames snap to guides.

  • How to get File  object from Document Object . ?

    In conventional Dom Parsing we pass file to DocumentBuilder to get Document Object .
      File file = new File("c:\\MyXMLFile.xml");
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      DocumentBuilder db = dbf.newDocumentBuilder();
      Document doc = db.parse(file); // gOT Document here . My problem is how do i get File object back from Document . If i have Document object with mi.
    Please consider above code as example i dont have File object in my code . i am using Xhive DB API where i get Document directly from API method .
    I need to convert this Document to File to get size of file
    Please suggest solution on this
    Edited by: AmitChalwade123456 on Dec 5, 2008 6:10 AM

    Hello Guys any views on this topic

  • Create a File object from a file in a .jar

    i looked for 2 hours...
    i tired this:
    URL url =  MyClass.class.getResource("filename.dat");
    File file = new File(url.getFile());i give up.

    The problem is that the file inside a Jar file is not
    a file. The jar file just contains a stream of bytes
    in the format needed to make the Jar file. Jar files
    are not folders like in the directory. So to get at
    the contents of the Jar file you need to read the Jar.
    The getResource method returns the URL which is a
    file URL, but this only works because Java has
    handlers that deal with getting the contents from a
    Jar file based on this type of URL. A URL cannot
    just be made into a file. I'm not sure that the File
    object can handle this type of file URL (I guess not
    or we wouldn't be having this discussion). So really
    it just depends what you want do. If you want to
    extract the file, just read the data in from the
    inputstream gotten from the URL, or better just call
    getResourceAsStream(), and read the bytes into an
    array. After this, you can do whatever, write it as
    a file to the hard drive, convert to a string, get
    the size based on the array length. makes sense, but how could i get an InputStream into an array, dont i need the size of the array first? and i dont think i can use InputStream.available()to figure it out... i tired downcasting to a FileInputStream yet no avail.

  • Problem with editing the size of artboard and objects in illustrator!

    I was using a custom size of artboard in illustrator, but I now I want to change it to A4 size for printing. However, when I change it to a A4 size artboard, the size of objects on that artboard remain unchange. As a result these objects do not fit the new size of artboard. Are there any way that I can change both the size of artboard and objects at once? Thank you!

    Probably not.  Don't suppose you have a proportion scale handy?  Alright, don't worry about it.  Give me the size of your original ( in inches ) and the size of A4 ( in inches ), I can give you the scale percentage ( you input into the scale dialog box ).  Whatever you do, keep your original file and do the enlargement on a "copy" of the original.  You already have the new artboard, not it is just a simple matter of enlarging the artwork to fit the new size.

  • How can I store a File object into a Vector and get it back

    hi there
    I need to store a number of File object into a Vector first, and later on I need to get each File object out and work with it.
    Vector mylist;
    File[] myfile;
    ....get a list of files from using File Chooser
    mylist = new Vetor();
    for (i=0;i<myfile.length;i++){
    mylist.add(myfile);
    ..how do I get them back? i try to do this way
    for (i=0;i<mylist.size(); i++)
    File tempfile = mylist.get(i);
    ..work with tempfile. but I got java.lang.object error: imcompatible types. what can I do?

    Vector mylist;
    File[] myfile;
    ....get a list of files from using File Chooser
    mylist = new Vetor();
    for (i=0;i<myfile.length;i++){
    mylist.add(myfile);
    ok try this: i don't reall understand what your trying to do though...
    File[] files;
    // get files
    Vector fileList = new Vector();
    for (int i = 0; i < files.length; i++)
      fileList.add(files);
    // to get them out.
    for (int i = 0; i < fileList.size(); i++)
    ((File)fileList.elementAt(i)).toString();
    // or
    // to get them out.
    for (int i = 0; i < fileList.size(); i++)
    File temp = (File)fileList.elementAt(i);
    System.out.println(temp.toString);

  • The size of the file depends how long the application must wait?

    hi all
    We have build an FLEX application where the user can create an object in SAP. One of the properties of this object is a file.
    We had noticed that when the size of the file increases, also the time increases of the processing duration of FLEX to send all data to SAP and to return a succesfull message.
    When i set a breakpoint in the ABAP code which is called via a web service by FLEX, it is reached very quickly.
    This is the last line of ABAP code and after this SAP has completed its work. So a successmessage returns to FLEX after it
    But the time, when FLEX returns this message to the user depends on the size of the file which was send to SAP.
    When we send a file of 2 MB it is significant slower then a file of 0,2 MB. And not slower in the traffic SAP - FLEX or the processing in ABAP, but the processing of FLEX after the service call to SAP.
    Does anybody have experienced this also? And if so, what can we do about it?
    Kind regards,
    Anton Pierhagen

    hmm. i dont think there is any knowledge here about this subject. So i am closing this thread.

  • Create Class objects from an Array of File Objects

    Hi There,
    I'm having extreme difficulty in trying to convert an array of file objects to Class objects. My problem is as follows: I'm using Jfilechooser to select a directory and get an array of files of which are all .class files. I want to create Class objects from these .class files. Therefore, i can extract all the constructor, method and field information. I eventually want this class information to display in a JTree. Very similar to the explorer used in Netbeans. I've already created some code below, but it seems to be throwing a NoSuchMethodError exception. Can anyone please help??
    Thanks in advance,
    Vikash
    /* the following is the class im using */
    class FileClassLoader extends ClassLoader {
    private File file;
    public FileClassLoader (File ff) {
    this.file = ff;
    protected synchronized Class loadClass() throws ClassNotFoundException {
    Class c = null;
    try {
    // Get size of class file
    int size = (int)file.length();
    // Reserve space to read
    byte buff[] = new byte[size];
    // Get stream to read from
    FileInputStream fis = new FileInputStream(file);
    DataInputStream dis = new DataInputStream (fis);
    // Read in data
    dis.readFully (buff);
    // close stream
    dis.close();
    // get class name and remove ".class"
    String classname = null;
    String filename = file.getName();
    int i = filename.lastIndexOf('.');
    if(i>0 && i<filename.length()-1) {
    classname = filename.substring(0,i);
    // create class object from bytes
    c = defineClass (classname, buff, 0, buff.length);
    resolveClass (c);
    } catch (java.io.IOException e) {
    e.printStackTrace();
    return c;
    } // end of method loadClass
    } // end of class FileClassLoader
    /* The above class is used in the following button action in my gui */
    /* At the moment im trying to output the data to standard output */
    private void SelectPackage_but2ActionPerformed(java.awt.event.ActionEvent evt) {
    final JFileChooser f = new JFileChooser();
    f.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int rVal = f.showOpenDialog(Remedy.this);
    // selects directory
    File dir = f.getSelectedFile();
    // gets a list of files within the directory
    File[] allfiles = dir.listFiles();
    // for loop to filter out all the .class files
    for (int k=0; k < allfiles.length; k++) {
    if (allfiles[k].getName().endsWith(".class")) {
    try {
    System.out.println("File name: " + allfiles[k].getName()); // used for debugging
    FileClassLoader loader = new FileClassLoader(allfiles[k]);
    Class cl = loader.loadClass();
    //Class cl = null;
    Class[] interfaces = cl.getInterfaces();
    java.lang.reflect.Method[] methods = cl.getDeclaredMethods();
    java.lang.reflect.Field[] fields = cl.getDeclaredFields();
    System.out.println("Class Name: " + cl.getName());
    //print out methods
    for (int m=0; m < methods.length; m++) {
    System.out.println("Method: " + methods[m].getName());
    // print out fields
    for (int fld=0; fld < fields.length; fld++) {
    System.out.println("Field: " + fields[fld].getName());
    } catch (Exception e) {
    e.printStackTrace();
    } // end of if loop
    } // end of for loop
    packageName2.setText(dir.getPath());
    }

    It's throwing the exeption on the line:
    FileClassLoader loader = new FileClassLoader(allfiles[k]);
    I'm sure its something to do with the extended class i've created. but i cant seem to figure it out..
    Thanks if you can figure it out

  • Getting the size of a file without reading it

    Hello we are currently implementing a file upload/download framework in our application.
    The framework will included multiple filters such as for file mime types, suffices and size of the file.
    However, for the size filter, we want to check the size without reading it. This is because reading a file which we would later find unacceptable for our application would mean that we are wasting the resources. 
    Since we are currently using an IWDResource object to implement the framework, the method
             IWDResource.getStream(false).available()                                                                                may not come in handy as it seems to read the file to find out its size.
    I need to know whether there is some other method or approach we can emply, using IWDResource object, that will not read the file to find out the size.
    Thanks alot in advance.

    But, it doesn't give me an error, it just gives me the length of the URL, and for some reason it also adds 'D:\jsdk1.4\bin' to the beginning of my URL, so instead of
    File webFile = new File(webFileURL.toString());and you would think that it would be similar code to:
    File webFile = new File("http://66.185.95.103/8989898904/miko17a.avi");but instead, i've checked the File name, and it was
    D:/jsdk1.4/bin/http://66.185.95.103/8989898904/miko17a.avi
    or similar code...
    File webFile = new File("D:/jsdk1.4/bin/http://66.185.95.103/8989898904/miko17a.avi");why does it add the bin folder of my Java SDK to the beginning??? if it didn't do that, everything would be fine...

  • 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 to find out the size of a file?

    Hi,
    I would like to determine the size of a file from my code. How is that possible? I do not find any appropriate method in the java.io.File class.
    Any help would be very appreciated!

    java.io.File.length()
    Returns the size of the file as a long. The number corresponds to the number of bytes in the file.

  • 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 change the size of a particular object in the picture?

    How to change the size of a particular object in the picture?

    You need to select it.  Copy that selection to a new layer, and use Free Transform to resize it.
    http://www.youtube.com/watch?v=qWpAGmwhllQ
    http://www.youtube.com/watch?v=Bi4jJnYLkUA

Maybe you are looking for

  • Can you add page turning to a pdf?

    I have added dynamic link to my contents page and would like to add a 'page turning' effect at the foot of each page - a sort of animated book. Can I achieve this using Acrobat Professional?

  • Changing the day start time

    I'm a sudent at uni, and so often go out for the evening, and return sometime in the early hours of the next morning. Is it at all possible to change the settings so tat a day begins at 4 a.m. rather than midnight?

  • Run Adobe AIR app as Windows Service

    I have an app which monitors an RSS feed. Upon an emergency, the RSS feed is updated. The app detects the change and launches (from the taskbar/dock) full screen, plays an alarm sound and displays the message. Is it possible to run this app as a serv

  • Newbie Having Trouble with MaxDate

    First let me say that I am pretty new to writing code, so I apologize if I don't use the correct terminology. Now to my issue. I'm trying to write a query that will return several date fields. The problem is that there can be several instances for ea

  • Unable to run reports in Campus Manager 5.2.2

    I'm trying to run reports in Campus Manager and none of them work. If I try a Best Practices Deviation report I get this error: "Problem with File /WEB-INF/screens/reports/BestPracticesReportGen.jsp!!!/WEB-INF/screens/reporst/BestPracticesReportGen.j