Writing a tempfile that doesn't always the write full amount of data

I am writing my xml string to a text file so I can parse the xml in my servlet. Most of the time it works great, but it sometimes the output does not contain all the data I am trying to write.
I can successfuly write files as long a 62,000 characters but some times the data is truncated and I get a
SaxparserException because the xml is not complete.
We are using JavaTM 2 Platform Std. Ed. v1.3.
Here is my code - could someone please tell me if there is a size limit... etc..
public Document parseV(String xmlFile) throws Exception {
File temp = File.createTempFile("PolicySummary", ".aocs");
PrintWriter out = new PrintWriter(new BufferedWriter (new FileWriter(temp), xmlFile.length()));
out.print(xmlFile);
System.out.println("temp file " + temp.getAbsolutePath());
String xmlPath = temp.getAbsolutePath();
try {
// Get a new parser and attach an error handler
DOMParser myParser = new DOMParser();
// Parse the file
myParser.parse(xmlPath);
out.close();
out.flush();
temp.deleteOnExit();
document = myParser.getDocument();
return document;
} catch (MalformedURLException e) { System.err.println("Problem Parsing XML file, tag missing : " );
return null;
Is there a better way??
Thanks in advance for your help!

When you post code, please use [code] and [/code] tags as described in Formatting Help on the message entry page. It makes it much easier to read and prevents accidental markup from array indices like [i].
First, calling flush() after calling close() does nothing. Second, since you use a BufferedWriter and parse before you close/flush, you're not getting all the content. move your delete the call to flush(), and move your out.close() statement before your parse() call.

Similar Messages

  • How do you make a portrait view that doesn't loose the pictures?

    I'm trying to layout a portrait view book in iBooks Author and I don't understand why Apple doesn't include a template that doesn't lose the pictures when you change screen orientation. Seeing that 99.9% percent of all paper books in the world are in portrait view I would have expected this to be the default view rather than landscape view. Has anybody been able to make a portrait view book that retains the graphics and other bells and whistles or am I just banging my head against the wall?

    In portrait mode the figures and things are always links down the side of the text. The only way I found to stop them disappearing was to insert them in portrait mode. They don't disappear when you change back to landscape, you just have to move them to wherever it is you want them to be. The best workflow is edit in portrait, then switch to landscape for formatting.

  • Camera app that doesn't flip the image

    Hello guys, does anyone know an app in the app store that doesn't mirror the image?
    The app also needs to be free.
    Thanks,
    regirock524

    I'm pretty sure that regardless of which camera app is used, the photos always end up on the "camera roll", and will therefore be treated equally by the OS.  I'd suggest a separate camera for your amputated fingertips.  

  • How can I delete an app from launchpad, that doesn't have the little cross in the left top corner. The app isn't an App Store app. The application is also not present anymore in my application's folder in finder.

    How can I delete an app from launchpad, that doesn't have the little cross in the left top corner. The app isn't an App Store app. The application is also not present anymore in my application's folder in finder.
    I tried to use the attached command through TERMINAL :
    sqlite3 ~/Library/Application\ Support/Dock/*.db "DELETE from apps WHERE title='Help';" && killall Dock
    sqlite3: Error: too many options: "DELETE from apps WHERE title='Help';"
    Use -help for a list of options.
    But i didn't work as I got the above error message.
    best regards
    Jeroen

    I'm in the same boat as you -- except that I manage both a school lab (volunteer job) and macs in the enterprise (pay job).  What I think we need is the Education Volume Purchasing Program
    http://www.apple.com/education/volume-purchase-program/faq.html
    Unfortunately this all seems a little rough around the edges -- for example, I have found updates for AppStore apps on the support.apple.com updates download site, but then when I install them via ARD they don't actually update the software.  (The AppStore icons still show as needing the updates, and the version info reports the old version.)  The documentation is also vague about which AppleID to use in which circumstance.  I think they just haven't finished thinking through the implications of the various procedures and policies upon the various kinds of customers.  When we deployed Mountain Lion on the school lab, we made an install usb and went around and installed it on each computer -- and it appears that you are on the honor system as far as paying for all of the licenses that you install.  We did!  But they appear to have no way to enforce it.
    So far, I have only deployed 9 Lion macs in my day job, and our "solution" to the AppStore showing updates problem has been to drag the AppStore icon off of the users' docks so they don't see them!

  • Is there some way to add multiple addresses to an email I am sending that doesn't close the contact list after I click on an address?  This necessitates constantly going back to click the + sign to add each address separately.

    Is there some way to add multiple addresses to an email I am sending that doesn't close the contact list after I click on an address?  This necessitates constantly going back to click the + sign to add each address separately.  Is there some way I can open the contact list, click on all of the individual addresses to which I want to send the email without the list closing between each address entry, and have all of my address entries be listed to the email at one time?  Something like it works in Gmail.  I do not want to use set lists, I want to enter different addresses each time I send an email.  And I am a very slow typist, so I don't want to type the first few letters of each recipient's name.  It is much faster for me to just click on the e-mail addresses in the list as a group.  It doesn't make any sense to me to have to reopen the contact list for each address, when it should be so easy to click on all of the addresses I want at one time and then click once to add them all to the email as a group.  If there is a solution to this, please tell me.  Thanks.

    Vatlily,
    Try this:
    1. Select Mail>File>New Message.
    2. Select Mail>Window>Address Panel.
    3. Use (command+click) on the desired addressees in the Address Panel to create the list.
    4. Click "To:" on the top left of the Address Panel.
    The group that you selected will be added to the "To" field in your New Message.

  • When trying to upload a MS word file (.docx) to gmail, it uploads into a folder that doesn't contain the original document when i try to download it from e-mail.  how do i solve this?

    when trying to upload a MS word file (.docx) to gmail, it uploads as a 'folder' that doesn't contain the original document when i try to download it back from the e-mail.  how do i set the format to simply upload the document itself???  Thanks...

    Yes, excuse me. attach a file.  I have separate folders on my desktop to organize my word documents, so I'm guessing this might be a part of the problem.  When I go to attach one of these documents into gmail, the resulting attachment is another folder icon (not the original organizational folders) with 4 subfolders containing a slew of .xml files reading things like "header.xml" "format.xml" "settings.xml" "style.xml" "contenttype.xml" There are also a few .jpegs and a small folder reading "word" as one of the subfolders.

  • How do i delete a stationery in mail that doesn't have the X

    How do i delete a stationery in mail that doesn't have the X to delete it and its beger then the rest of my other stationery

    "when I try save to PDF it just wants to save it to a file?"
    Correct. The difference between "Mail PDF" and "Save PDF" is that the first opens a new Mail message with the file attached. the second saves a file which you may attach to an email message.
    "Terrainathome is a good example of what I am trying to do."
    Not familiar with Terrainathome, but my guess is that the company is sending an email message containing HTML code that downloads what's essentially a web page into the displayed message. To do that, you'll need a website, software that will produce the necessary HTML code, and recipients with email clients capable of interpreting HTML (which is 'most email clients' these days).
    Regards,
    Barry

  • When I start Firefox, I only get the background of my browser in the Firefox window. I already reinstalled it, but that doesn't fix the problem.

    When I start Firefox, I only get the background of my browser in the Firefox window. I the normal window for 1 second, but then it changes in only the background window. So without toolbar, or navigation. I already reinstalled it, but that doesn't fix the problem.

    Try to disable hardware acceleration in Firefox.
    Tools > Options > Advanced > General > Browsing: "Use hardware acceleration when available"
    https://hacks.mozilla.org/2010/09/hardware-acceleration/
    https://support.mozilla.org/kb/how-do-i-upgrade-my-graphics-drivers

  • How to create a task list view in c# that doesn't display the timeline

    How can I create a view for a task list using c# that doesn't display the timeline.  I want to do this using server side code but I can't seem to find a view property that will hide the timeline.  I know how to do it manually through the UI but
    I need to automate it.
    Caroline

    Hi Garoline,
    We can set ViewData of the view to empty to achieve your requirement. The following code snippet for your reference:
    using (SPSite site = new SPSite("http://sp2013sps/"))
    using (SPWeb web = site.OpenWeb())
    SPList list = web.Lists["TaskList"];
    SPViewCollection allviews = list.Views;
    string viewName = "Test View";
    System.Collections.Specialized.StringCollection viewFields = new System.Collections.Specialized.StringCollection();
    viewFields.Add("Checkmark");
    viewFields.Add("LinkTitle");
    viewFields.Add("Due Date");
    viewFields.Add("Assigned To");
    string myquery = "<where><gt><fieldref name='ID' /><value type='Counter'>0</value></gt></where>";
    allviews.Add(viewName, viewFields, myquery, 100, true, false);
    SPView view=list.Views[viewName];
    view.ViewData = "";
    view.Update();
    Best Regards,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • HT1947 Is there a way to get a list view for movies? Something that doesn't truncate the titles?

    Is there a way to get a list view for movies? Something that doesn't truncate the titles?

    I don't think the following is too uncommon;
    total_training_ c1_getting_started_on_windows
    total_training_c2_getting_started_on_mac
    total_training_c3_orgainizing_photo_on_windows
    total_training_c4_organizing_photos_on_mac
    total_training_c5_fixing_common_problems
    total_training_c6_adjusting_exposure
    total_training_c7_adjusting_color
    total_training_c8_sharing_your_photos
    total_training_c9_work_with_text
    total_training_c10_retouching_your_photos
    total_training_c11_compositing_images_and_adding_effects
    total_training_c12_photoshop_elements_creations

  • My iphone won't turn on. I've tried resetting but that doesn't help, the apple icon comes up then disappears.

    My iphone won't turn on. I've tried resetting it but that doesn't help, the apple icon comes on then disappears. Please help!!

    See this: http://support.apple.com/kb/HT1808

  • With journaling, I have found that my computer is saving a large amount of data, logs of all the changes I make to files; how can I clean up these logs?

    With journaling, I have found that my computer is saving a large amount of data, logs of all the changes I make to files; how can I clean up these logs?
    For example, in Notes, I have written three notes; however if I click on 'All On My Mac' on the side bar, I see about 10 different versions of each note I make, it saves a version every time I add or delete a sentence.
    I also noticed, that when I write an email, Mail saves about 10 or more draft versions before the final is sent.
    I understand that all this journaling provides a level of security, and prevents data lost; but I was wondering, is there a function to clean up journal logs once in a while?
    Thanks
    Roz

    Are you using Microsoft word?  Microsoft thinks the users are idiots. They put up a lot of pointless messages that annoy & worry users.  I have seen this message from Microsoft word.  It's annoying.
    As BDaqua points out...
    When you copy information via edit > copy,  command + c, edit > cut, or command +x, you place the information on the clipboard. When you paste information, edit > paste or command + v, you copy information from the clipboard to your data file.
    If you edit > cut or command + x and you do not paste the information and you quite Word, you could be loosing information.  Microsoft is very worried about this. When you quite Word, Microsoft checks if there is information on the clipboard & if so, Microsoft puts out this message.
    You should be saving your work more than once a day. I'd save every 5 minutes.  command + s does a save.
    Robert

  • I have an iPhone 4 and I want to upgrade it to iOS 5. Is there any way that I can upgrade the iOS and keep my data and apps?

    I have an iPhone 4 and I want to upgrade it to iOS 5. Is there any way that I can upgrade the iOS and keep my data and apps?

    why would you think you'd lose them?

  • Time machine always backs up same amount of data

    When backing up with Time Machine it always backs up the same amount of data each time (140GB).  I am not modifying 140GB of data each day or even each week so why does Time Machine always default to this amount of data?
    I would like TM to only backup modified data so that I am not waiting hours for TM to complete backup.  Looking for a reset or workaround for this issue. 
    Mac Pro 10.8

    See D4 in the 1st linked article.
    Time Machine Troubleshooting
    Time Machine Troubleshooting Problems

  • Why won't Firefox always minimize/resize? Using F11 is a patchy solution that doesn't always work

    Firefox won't always minimize or resize. The upper right hand corner just pulsates. Looking through forums, I found that using f11 can help, but it doesn't always work. Often I have to reboot.
    == This happened ==
    Not sure how often
    == A year ago, maybe

    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    * Don't make any changes on the Safe mode start window.
    See:
    * [[Troubleshooting extensions and themes]]
    * [[Troubleshooting plugins]]
    If it does work in Safe-mode then disable all extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
    * Use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.
    * Close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")

Maybe you are looking for