Read once, use always??

All,
What would be the best practice when dealing with big files ... (say couple of MBs).
Instead of having to read the file from the file system everytime a static method is run, what would be the best way in which the program reads the file once and then keeps it in memory. So the next time it would not have to read and parse it all over again?
Currently my code just read the file in the static method like ...
public static String doOperation(String path,...) throws Exception
try{           
String masterFile = path+"configfile.xml";
Document theFile = (Document)getDocument(masterFile);
// ... operations on file
Optimization tips and tricks most appreciated :-)
Thanks,
David

How about remembering what was done or returned the previous time the method was run and just doing that again if the same file is passed and it hasn't been modified in the meantime? Or keeping the parsed file in a static variable so it doesn't need to be read and parsed again?

Similar Messages

  • Why that when I record a video in my iPhone 4s then I will transfer it to my laptop, the video is in slow motion? Please help so that I can use always my video recording feature. Thanks!

    Why that when I record a video in my iPhone 4s then I will transfer it to my laptop, the video is in slow motion? Please help so that I can use always my video recording feature. Thanks!

    Video is synced from the computer to the iPhone via iTunes. You need to load the video into iTunes, make sure it is iPhone compatible before you do that, and once it is in iTunes, then sync to the iPhone.
    Never said what computer OS you were using. Also, the computer processor, amount of RAM can make a difference with HD video.

  • Reading request using ServletRequest.getInputStream() and getParameter()

    Hi,
    I have following problem: I have to read request using getInputStream()-method, because there might be an attachment in the form. Problem is that I have to read same request using ServletRequest.getParameter()-method. As it is said in API-documentation using getInputStream may interfere execution of ServletRequest.getParameter()-method. An so it does.
    Tomi

    You need to use the methods supplied by the
    MultipartRequest class to read in the parameters of
    the form because once you create a MultipartRequest
    object it reads in all the attachments and form
    parameters and then closes the input stream, so you
    can't use the 'getParameter' method of the HttpServlet
    class anymore.Exactly but then you have to define every jsp-page <form enctype="multipart/data-form" >. That's big problem because we are not using always multipart/data-form. Not always even post-method. However we are always using same servlet. This MultipartRequest-class assumes that it's multipart form.
    Tomi
    >
    The MultipartRequest has methods called
    'getParameter','getParameterNames', etc. that mimic
    the method names of the ServletRequest class. See the
    API doc below:
    http://www.servlets.com/cos/javadoc/com/oreilly/servlet
    MultipartRequest.html

  • Insert data into multiple entities at once using a view object

    Hi,
    I'm trying to insert data into multiple entities at once using a view object, but unfortunately it doesn't seem to work. The two entities have a 1:1 association. I created a view object which contains both entities and I made sure they aren't read-only. But like I said it doesn't work, I can't insert data in both entities at once... :(
    Is this possible? And how (if it is)?

    Hi,
    I'm trying to insert data into multiple entities at once using a view object, but unfortunately it doesn't seem to work. The two entities have a 1:1 association. I created a view object which contains both entities and I made sure they aren't read-only. But like I said it doesn't work, I can't insert data in both entities at once... :(
    Is this possible? And how (if it is)? Peter:
    This is definitely supported and tested. Please send us the exception stack trace. You must running into other problems. A few things to note:
    A) You have to mark the entities as both updateable (not read-only) and not reference-only.
    B) If you're not seeing an exception stack, turn on diagnostic. Here is how:
    To turn on diagnostic, go to the IDE,
    1. Select the project.
    2. Do right mouse click and select "Project Settings..."
    3. On the Settings dialog, select Configurations/Runner.
    4. In the righthand side pane, you should see a textbox for "Java
    Options". Please add the following JVM switch:
    -Djbo.debugoutput=console
    Then, rerun. The run command should include
    -Djbo.debugoutput=console as in
    "D:\JDev9i\jdk\bin\javaw.exe" -Djbo.debugoutput=console -classpath ...
    You should now see a lot more output on the IDE's message window. Here you should see the exception stack trace.
    If you invoking your app directly from command prompt, just add "-Djbo.debugoutput=console" after your "java.exe".
    Thanks.
    Sung

  • I tried opening a pdf file and I set it to use always and firefox which did not work, I was wondering how to undo that and what I should use to open pdf files in the future?

    I was attempting to open a document from a frequently used site, I had never been on, on my new mac however. I attempted to open the pdf file and was given the option of which program to use to open it, I mistakenly clicked use always and firefox as the program with which to open pdf files. I do not know how to undo this or what I should do in the future to access the pdf files.

    Hi Melfour-
    Here is a Support article detailing how to work with your Firefox PDF preferences:
    [[Opening PDF files within Firefox]]
    Hope that helps.

  • Why cant poll a file more than once using File Adapter..

    Hi All,
    When we run webservice, as I am using File Adapter to read/write the file information.
    Usually, File Adapter reads once every file and it wont read again the same file whcih already red.
    Where and How this status maintained by File Adapter/BPEL in the system.
    Where this will be avvailable and why cant File Adapter read/poll the same file.
    Pls can any one of you share your ideas on the same.
    Thanks.

    Hi,
    Tried to get some information around where ftp adapter stores the timestamp but couldnt find anything useful.
    But we have a table for File adapter which captures the processing information (FILEADAPTER_IN )
    I dont have the setup for FTP adapter to run an example. If you could try the below we can clarify that the timestamp is not stored in memory.
    Configure as usual for a folder with a file pattern for FTP adapter.
    Drop a file to process it and then restart the SOA Suite and try to drop the same file with same timestamp to see wheather FTP adapter picks up or not.
    Ideally i feel once you restart the SOA Suite it should pick up the file, if still not picks up the file for second time then we need to dig indepth to see where this information is stored.
    btw what is your usecase ?
    Thanks,
    Vijay
    Edited by: veejai24 on 11-Apr-2012 03:43

  • 've recently upgraded to FireFox v22.0. Originally, a legacy XBAP I use always opened correctly in FireFox and had no problems displaying or running. As of v22.

    I've recently upgraded to FireFox 22. Originally, a legacy XBAP I use always opened correctly in FireFox and had no problems displaying or running. As of 22, it won't even attempt to download the application, let alone try and display it.
    I have the windows Presentation Foundation 3.5.30729.1 installed, which is the same version I have been using in older versions.
    Can anyone shed some light on any changes that would have effected this?

    Hi, I have a similar problem. I did attempt the *.rdf fix on a test system, but it didn't work (em:maxVersion was already 22).
    We got about inflow of phone calls from our clients experiencing the problem mentioned above from the 2nd of July onwards... and more are phoning in.
    All the complaints come from clients (+- 10 so far and rising in number) using Firefox v22 (we have checked), and all of them have said that it was working previously.
    We downgraded one of the clients to an older version of Firefox, and it worked again. So far we are telling our clients to downgrade until a fix comes out, or use Internet Explorer (*blush*)

  • When I used download sets of photos, movies etc, (before I installed Lion) I used always get a "Download" gizmo which showed me the download happening with both speed and time left.  Now with Lion, nothing shows on my screen.  Can I fix this?

    When I used download sets of photos, movies etc, (before I installed Lion) I used always get a "Download" gizmo which showed me the download happening with both speed and time left.  Now with Lion, nothing shows on my screen.  Can I fix this?

    In Firefox Options / Privacy be sure "Remember download history" is checked. To see all of the options on that panel, "Firefox will" must be set to "Use custom settings for history".
    To find your OS information, on your Windows desktop, right-click the My Computer icon, choose Properties, under System on that small window is info about your OS.
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''

  • How do i send a message to all my contacts on skype at once using MAC ?

    how do i send a message to all my contacts on skype at once using MAC ? it works on windows with Clownfish but not mac?

    Hi Body, Here is how you can send a message to all of your contacts and keep sending untill you close the skype application: 1 - Open any one of your skype contact as you would normally open for sending a messages or chatting.2 - click the + icon on the top.3 - select "Add People"4 - Now there will be two windows one is filled with your existing contacts and the other one is for selected contacts that you want to add as recievers5 - In left Panel, select all of your contacts and add them to right panel. ( You can do it by Pressing "CTRL+A".6 - see the bottom under left panel and press "Select"7 - Now you will see all your contacts in right panel8 - press "Add" button under right panel9 - done!

  • Labview misses a read when using Ni USB 8473 can interface

    I was wondering if anybody here has had experience with this problem... I already talked to a Labview tech but i have not received an answer yet...
    This is my problem..
    I have a program that  when a button is pressed, it initializes a can interface to CAN0 for example, then it writes... then it waits about 100mills and then it reads... My computer is connected to a simulator through the USB 8473 interface (I have the problem when I connect it to the hardware I am going to use), and everytime I write, this simulator sends a response... The problem is that sometimes I don't see a response... I have made sure that the simulator responds so I know it is responding... I have changed the waiting time before the read from 1 mills to 100 mills to 1 second, and still with the same result... 
    The way I have fixed this problem is by reading multiple times (3 times)... so every time I send a request, i wait 100 mills... then I read once, wait 25 mills, then read again, wait, then read again....
    So, I wanted to know if anybody here has had to do this in order to get around this problem...???
    The reason why I was asking this is because I also have another application that has to monitor my hardware by sending requests every 100 milliseconds... so I have two loops, once that writes requests every 100 mills... and another that reads the responses every 20 mills... but sometimes it looks like eventhough i read this many times, I still miss some frames, which are caught later but still not good enough...
    I have posted a different thread about the above problem...
    If you have questions just ask please...
    Thanks

    Yes, by Labview tech i meant NI Support... sorry about that...
    I am still waiting for them on this subject...
    I'll attach a simplified version of my code (the only difference between this code and the original is that i parse all the data that i get...)
    I am attaching these if a couple replys... 
    Run the receive and respond (simulator) then run the CAN_PROBLEM vi... click on the OK button to write then read... you can tell it missed the message when the Frames to Read field is 0...
     how are you sure that you device is sending a response?
    Very sure... 100%... the original simulator lets me know when it sends the response...
    Can you run bus monitor on another port, ie another USB-CAN device?
    I did that, and the other USB-CAN gets it... the program I am running on the other computer is called CANyliser... I think that program waits until there is something in the queue (which I am not doing with mine)... I am just reading after I have wrote teh message (reading after about 100 mills I wrote)... So I am assuming that's plenty of time... i have increased this waiting time to 1 sec and still get the same behaviour...
    Attachments:
    CAN_PROBLEM.vi ‏16 KB
    ReceiveAndRespond.vi ‏17 KB
    CAN INIT.vi ‏23 KB

  • When a read receipt shows delivered, will it then show read once it's has been read?

    when a read receipt shows delivered in messaging,will it then show read once it's has been read?

    Lets think about this for a bit. You have no problem when sending from Thunderbird. You have the problem when sending from 2 different Android smart phones that Thunderbird does not run on. You are connecting to your IMAP email account that is run by your email provider and viewing the folders on your provider's mail server.
    You are threatening to stop using Thunderbird? The one part of this equation that works. It is free software so I am sure Thunderbird will not miss the lack of revenue. I am just trying to understand your logic or lack there of.

  • My adobe reader once installed changes all of my files to pdf files...Why?

    Adobe reader once installed changes all of my files to pdf files...why?

    http://helpx.adobe.com/acrobat/kb/application-file-icons-change-acrobat.html

  • I have huge lag with Safari's Reading List using a rMBP. I have probably 80 articles saved, which is likely the cause of the lag. Is there any way to export that list of articles so as to be able to delete them from Reading List but still have a record?

    I have huge lag with Safari's Reading List using a rMBP. I have probably 80 articles saved, which is likely the cause of the lag. Is there any way to export that list of articles so as to be able to delete them from Reading List but still have a record of the articles I intend to read?

    I'm currently dealing with this issue myself, except that my rMBP has NO articles in the reading list.  It's a brand new rMBP too, purchased just this week, with the 2.6 Ghz Processor & 16GB of RAM.
    Let's see what we can find.  I may just take it back to the Apple Store.

  • Open several PDFs in the same Reader window using tabs for each document

    How do I open several PDFs in the same Reader window using tabs for each document?  I'm using Reader 11.0.03 and Windows 7.  

    That would be a nice feature!  Suggest it at https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform - hopefully it will make it into Reader XII.

  • Can't read email using my primary apple email account

    Ok, I'm new to this forum but here is my problem
    Usually I can read Email using my primary Apple E-mail account BEFORE I updated my Ipad into IOS 8.
    After I updated my Ipad into IOS 8 (non-jailbreak and from IOS 5 jailbreak), My Ipad says that I need to sign up an Icloud email to use the Mail App.
    Then I can't use my Primary Apple Account as an E-mail anymore. When people send a mail to my primary apple account, I cant read it because I cant read emails using my Primary Apple Account anymore.
    When I signed in with my primary apple Email account and opened my Mail App, It used my Icloud email instead my primary apple email.
    I tried everything Include making an email aliases but my primary apple email uses @Yahoo.com and I can only use aliases of @Icloud.com
    Can someone please help me so I can read E-mails when people send an Email to my primary apple account? Because I need to see those subcription mails and change my password of my online game account(<- This one is URGENT).
    And sorry for my bad English because I'm Indonesian.

    Welcome to discussions,
    go to settings/mail, contacts.../your mail account/outgoing mail server settings/ and see if you put in the needed password to access your mail server.
    Also check out this help article about your issue for more tips: http://support.apple.com/kb/TS2770

Maybe you are looking for