Read(Load)/Write(Save) Problem

I have a form that is filled out by people and I want to save the information in a text file. I have done that well at least I think with the Save code. My problem is when I go to load the text file (.CMM file for my program), nothing happens but it does print out my File Loaded message in the console. Any idea where I am missing something? The getter and setter methods all seem to be correct...
private void SavePrefs() {
          File SavePrefs;
          // get filename:
          fc.setDialogTitle("Select Filename For Site Data");
          int result = fc.showSaveDialog(f);
          if (result == JOptionPane.OK_OPTION) {
               SavePrefs = fc.getSelectedFile();
               // default file extension ".CMM"
               if (!SavePrefs.getName().endsWith(".CMM")) {
                    // filename does not meet requirements:
                    System.out.println("NO CMIMS in filename");
                    SavePrefs = new File(SavePrefs.getAbsolutePath() + ".CMM");
               // continue with save code:
               System.out.println("File Selected:" + SavePrefs.toString());
               //Creates a .cmm file with all the data in it.
               FileOutputStream saveData;
               PrintStream data;
               try {
                    saveData = new FileOutputStream(SavePrefs.toString());
                    data= new PrintStream(saveData);
                    data.println("CLOSE YEAR="+_SitePropPanel.getCloseYear());
                    data.println("OPEN YEAH="+_SitePropPanel.getOpenYear());
                    //data.println("COL RATE = "+_SitePropPanel.getCollectionRate());
                    data.println("GAS RECOV STATE="+_SitePropPanel.getGasRecoveryState());
                    data.println("SITE CLOSED="+_SitePropPanel.getLandfillClosed());
                    data.flush();
                    data.close();
                    saveData.flush();
                    saveData.close();
               } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
               } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
               System.out.println("File Saved");
          // not OK selected (cancel or.?)
     private void LoadPrefs() {
          File loadPrefs;
          // get filename:
          fc.setDialogTitle("Select Filename For Site Data");
          int result = fc.showOpenDialog(f);
          if (result == JOptionPane.OK_OPTION) {
               loadPrefs = fc.getSelectedFile();
               // default file extension ".CMM"
               if (!loadPrefs.getName().endsWith(".CMM")) {
                    // filename does not meet requirements:
                    System.out.println("NO CMIMS in filename");
               // continue with save code:
               System.out.println("File Selected:" + loadPrefs.toString());
               Properties loadData = new Properties();
               try {
                    loadData.load( new FileReader( loadPrefs.toString() ) );
                    _SitePropPanel.setLandfillClosed(new Boolean(loadData.getProperty("SITE CLOSED")));
                    _SitePropPanel.setCloseYear(loadData.getProperty("CLOSE YEAR"));
                    _SitePropPanel.setOpenYear(loadData.getProperty("OPEN YEAR"));
                    //_SitePropPanel.setCollectionRate(loadData.getProperty("COL RATE"));
                    _SitePropPanel.setGasRecoveryState(new Boolean(loadData.getProperty("GAS RECOV STATE")));
               } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
               } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
               System.out.println("File Loaded");
     }

Hi sch,
i've been figuring out what is the problem and i think i found it.
Your saving the data with this.
data.println("CLOSE YEAR="+_SitePropPanel.getCloseYear());
data.println("OPEN YEAH="+_SitePropPanel.getOpenYear());
//data.println("COL RATE = "+_SitePropPanel.getCollectionRate());
data.println("GAS RECOV STATE="+_SitePropPanel.getGasRecoveryState());
data.println("SITE CLOSED="+_SitePropPanel.getLandfillClosed());
when trying to System.out the loadData (properties) you can see clearly that it prints out like this
CLOSE=YEAR, OPEN=YEAH, etc etc
so obvouisly your not setting correctly.
it works this way.
greetz Wiz
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Properties;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class Tester {
      * @param args
     JFileChooser fc = new JFileChooser();
     JFrame f;
     public static void main(String[] args) {
          // TODO Auto-generated method stub
          new Tester();
     public Tester() {
          f = new JFrame();
          f.setSize(800, 600);
          f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          f.setVisible(true);
//          SavePrefs();
          LoadPrefs();
     private void SavePrefs() {
          File SavePrefs;
          // get filename:
          fc.setDialogTitle("Select Filename For Site Data");
          int result = fc.showSaveDialog(f);
          if (result == JOptionPane.OK_OPTION) {
          SavePrefs = fc.getSelectedFile();
          // default file extension ".CMM"
          if (!SavePrefs.getName().endsWith(".CMM")) {
          // filename does not meet requirements:
          System.out.println("NO CMIMS in filename");
          SavePrefs = new File(SavePrefs.getAbsolutePath() + ".CMM");
          // continue with save code:
          System.out.println("File Selected:" + SavePrefs.toString());
          //Creates a .cmm file with all the data in it.
          FileOutputStream saveData;
          PrintStream data;
          try {
          saveData = new FileOutputStream(SavePrefs.toString());
          data= new PrintStream(saveData);
          data.println("CLOSEYEAR="+_SitePropPanel.getCloseYear());
          data.println("OPENYEAH="+_SitePropPanel.getOpenYear());
          //data.println("COL RATE = "+_SitePropPanel.getCollectionRate());
          data.println("GASRECOV STATE="+_SitePropPanel.getGasRecoveryState());
          data.println("SITECLOSED="+_SitePropPanel.getLandfillClosed());
          data.flush();
          data.close();
          saveData.flush();
          saveData.close();
          } catch (FileNotFoundException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          System.out.println("File Saved");
          // not OK selected (cancel or.?)
          private void LoadPrefs() {
          File loadPrefs;
          // get filename:
          fc.setDialogTitle("Select Filename For Site Data");
          int result = fc.showOpenDialog(f);
          if (result == JOptionPane.OK_OPTION) {
          loadPrefs = fc.getSelectedFile();
          // default file extension ".CMM"
          if (!loadPrefs.getName().endsWith(".CMM")) {
          // filename does not meet requirements:
          System.out.println("NO CMIMS in filename");
          // continue with save code:
          System.out.println("File Selected:" + loadPrefs.toString());
          Properties loadData = new Properties();
          try {
          new _SitePropPanel();
          loadData.load( new FileReader( loadPrefs.toString() ) );
          System.out.println(loadData);
          _SitePropPanel.setLandfillClosed(new Boolean(loadData.getProperty("SITECLOSED")));
          _SitePropPanel.setCloseYear(loadData.getProperty("CLOSEYEAR"));
          _SitePropPanel.setOpenYear(loadData.getProperty("OPENYEAR"));
          //_SitePropPanel.setCollectionRate(loadData.getProperty("COL RATE"));
          _SitePropPanel.setGasRecoveryState(new Boolean(loadData.getProperty("GASRECOVSTATE")));
          } catch (FileNotFoundException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          System.out.println("File Loaded");
}

Similar Messages

  • Read and write file problem

    hello
    I have web application and I try using servlet to upload an image
    upload proccess works fine
    example
    1. I upload the the file C:\images\books\mybook.gif into
    temp folder
    2. other actions
    3. I want to write the fole mybook.gif into othet folder
    this process oerks fine on my home pc
    but I becom an ecxeption by webprovider
    /home/mydomain/public_html/projects/tempData/C:\images\books\mybook.gif(No such file or directory)what shoud be the problem and how to solve this issue
    thanks

    here is the code of the uploadservlet
    public void doPost(HttpServletRequest request, HttpServletResponse response)
                   throws ServletException, IOException
        PrintWriter out = null;
        String tempUploadDir = request.getSession().getServletContext().getRealPath("/")+"MyTemp"+File.separator;
         try
              out = response.getWriter();
             response.setContentType("text/html");
             MultipartRequest parser = new ServletMultipartRequest(request,
                                                                               MultipartRequest.MAX_READ_BYTES,
                                                                               MultipartRequest.IGNORE_FILES_IF_MAX_BYES_EXCEEDED,
                                                                               null);
                 Enumeration files= parser.getFileParameterNames();
                      while(files.hasMoreElements()){
                                boolean sizeOK    = true;         
                                String name       = (String)files.nextElement();
                                String filename   = parser. getBaseFilename(name);
                              InputStream ins   = parser.getFileContents(name);
                              if((parser.getFileSize(name) / 1024) > AppConstants.MAX_READ_BYTES){sizeOK = false;}
                         if(sizeOK){
                              if (ins!=null)
                                      BufferedInputStream input = new BufferedInputStream(ins);
                                   FileOutputStream outfile = new FileOutputStream(new File("MyTemp",filename));
                                             int read;
                                             byte[] buffer = new byte[4096];
                                             while ((read=input.read(buffer))!=-1){
                                                        outfile.write(buffer, 0, read);
                                             outfile.close();
                                             input.close();
             }// end out while
         }catch (Exception e) {  out.flush(); }
    what is to change here thanks

  • Can't read or write some files, internet is failing, youtube won't load, software I tried to install was in Slovenian, not dutch or english like in my systempreferences settings, pictures and files won't preview with spacebar, etc. Malware?

    Specs:
    iMac 10.8.5
    3,4 GHz Intel Core i7
    32 GB 1600 MHz DDR3
    Can't read or write some files, internet is failing, youtube won't load, security software I tried to install was in Slovenian, not dutch or english like in my systempreferences settings, pictures and files won't preview with spacebar and are randomly corrupted, when I entered something in the Youtube searchbar (when it was still working) it send me to a site with sexadds.
    I tried restart my iMac and when I was logged back in, my dock preferences were reset.
    Also tried to download some security software to check my Mac for malware, but when I did, I tried several, I got a notification that said something like 'dumpfiles (don't know if this is the right translation...) damaged'.
    I'm taking screenshots from all the weird notifications I get and even three quarters off the screenshots I took in the last three hours are already unreadable.
    It started this morning when I tried opening a Premiere Pro file on which I worked the night before.
    When I tried opening it, it said the file was damaged and could not be openend.
    I tried opening it with AE or importing the file in a new project but nothing helped.
    When I tried looking for autosaves, this is the really weird part, there were none.
    Even though there are autosaves from my other projects, this one was completely gone.
    It looked like the day before never happened on my computer.
    Also when I openend Premiere all the recent projects had been wiped.
    So at first I thought it was a Premiere Pro failure.
    But than, later on the day, I tried loading some RAW files from my compact flash card.
    This is where I would get an error (error -36) which said some data cannot be read or written.
    I tried importing the files with a view different technics, from dragging to importing via Lightroom and I succeeded with Image Browser.
    But when I tried moving the files to an other folder the same error occurred.
    While dealing with this issue I wanted to put on some soothing music on youtube.
    This is when the next weird thing occurred: youtube wasn't completely loading in Chrome. I refreshed a view times, checked the internet connection and still no difference.
    When I tried in Safari it did work but when I clicked enter on the searchbar in Youtube, a page with sexadds appeared (I didn't install AdBlock in Safari...).
    I read about this 'phishing' where you are redirected to a site were a possible malware installment can take place...
    I don't know if it's connected to any of the problems I've been having but I just never experienced this on a mac, I have been a Mac user for 10 years now.
    On top of it all, internet started working worse and worse and now it's not even working at all. I had to fill in the password over and over, normally it remembers.
    Just like my system preferences, all the preferences I had with Chrome where also reset.
    Also somewhere in between I got this notification: Mac OS X must restore library to run programs. Type your password to allow.
    To me this is all very weird and suspicious. I have clearly no idea what's going on. Could this be another sort of trojan horse or malware?
    Some background info which could be helpful for solving this mystery:
    two months ago the one year old Fusion Drive in my iMac just broke out of nowhere.
    I got it replaced by a qualified apple repair store.
    When I got my computer back, all the files where gone.
    I got on the internet without AdBlock installed yet.
    A game or whatever it was, can't clearly remember, got installed by accident.
    I deleted it immediately.
    Only two weeks later, I couldn't log in to my account. It didn't recognize my password and username. 
    So I brought my mac back to the store.
    Here the repair guy said it was a minor thing and he just needed to reconnect my account. He also mentioned he found a downloaded game name Sparta and it probably had something to do with the error.
    I asked him; could it be a virus? He replied no way.
    I don't know why I couldn't be a virus, just because it's a mac doesn't mean it cannot be done.
    So today I tried installing anti virus software (such as avast- was in a weird language looked like slovenian, clamxav - was in slovenian) but I couldn't install them.
    PLEASE help me! I don't know what to do anymore, I work fulltime and I need my computer, I have no time to bring it in for repair, are there other perhaps easier ways?
    Could this be the work of a virus or a malware? Or is it a disk permissions issue?

    It sounds like you may have multiple problems, but none of them are likely to be caused by malware.
    First, the internet-related issues may be related to adware or a network compromise. I tend to lean more towards the latter, based on your description of the problem. See:
    http://www.adwaremedic.com/kb/baddns.php
    http://www.adwaremedic.com/kb/hackedrouter.php
    If investigation shows that this is not a network-specific issue, then it's probably adware. See my Adware Removal Guide for help finding and removing it. Note that you mention AdBlock as if it should have prevented this, but it's important to understand that ad blockers do not protect you against adware in any way. Neither would any kind of anti-virus software, which often doesn't detect adware.
    As for the other issues, it sounds like you've got some serious corruption. I would be inclined to say it sounds like a failing drive, except it sounds like you just got it replaced. How did you get all your files back after the new drive was installed?
    (Fair disclosure: I may receive compensation from links to my sites, TheSafeMac.com and AdwareMedic.com, in the form of buttons allowing for donations. Donations are not required to use my site or software.)

  • Windows 2008 R2 Folder assign permission "Read and Write" problem with *.doc file

    Hello All,
    I am a new one here,
    I am sorry for any mistakes and also my english is so poor.
    M Brother company runing Windows 2008 R2 as Active Directory...
    We have folder Name: Admin
    and in this folder, there are alot documents files as : *.doc, *.dwg, *.txt etc.....
    All user accesing to these files and they can open to edit and save...
    One day my brother want me to set Admin folder for all users just"Read and Write.." mean they still can open files to edit and save... but can't delete..
    I did success with this..
    But only one thing happen.. when they open *.doc file to edit and attempting to save, the message alert" access denide " and they can only "SAVE AS"...We don't want "Save as"
    Could you show me how can we fix error with *.doc file while they trying to save? because it allow only save as.. but other files as *.text file or *.dwg they can save without problem..
    Could expert here ever face this issues and fix by yourself, please share me with this..
    Please help me..
    Best regards,

    Hi,
    Office programs are specific. They will create a temp file when edit, then the temp file will be deleted when close. So Delete permission is needed for users to saving Office files like Excel/Word.
    For more detaile information, please refer to the thread below:
    Special Permissions - User cannot save files
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/721fb2f1-205b-46e5-a3dc-3029e5df9b5b/special-permissions-user-cannot-save-files
    Best Regards,
    Mandy 
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • I have an external hard drive, from Iomega. However, I cannot copy or save any file to it. On my PC it says that is possible to read and write in it, but in my Mac, it says I can only read. can somebody help me?

    I have an external hard drive, from Iomega. that I can open and see my files. However, I cannot copy or save any file to it. On my PC I have it says that is possible to read and write in it, but in my Mac, it says I can only read. can somebody help me?
    Also, Im a photographer, so I like to name a lot of files at the same time (used to do in on PC and it was very usefull.) cannot find out how to do it on my Mac. Really appretiate if some one can give me a solution! Thanx

    Your drive is formatted with the NTFS file system.  OS X can read but not write to the NTFS file system.  There are third party drivers available that claim to add the ability to OS X to write to an NTFS partition.  I have not tried them and don't know if they work.
    The only file system that OS X and Windows can both write to natively is the FAT32 file system.

  • "Attempted to read or write protected memory" error in loading a report.

    Development Environment
    ===
    Windows XP
    Visual Studio 2008 Pro; with Crystal Reports 2008 for Visual Studio
    TagetCPU: 'AnyCPU'
    VB.net 3.5
    Windows dll
    Crystal Reports Runtime SP2 (12.2.0.290)
    Deployment Environment
    ===
    Windows XP
    .net3.5
    Crystal Reports Runtime SP3 (no be confirmed)
    I have created a windows dll with a form with a reportdocument, that loads a report (CrystalDecisions.CrystalReports.Engine.ReportDocument).
    Then we circle through the report setting every table location to point at a specific ODBC and database.
    The Dll can do this process several hundred reports in a day. However a small number (less than 10) of these have the following error:
    "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
    This is normally occurring when the reportDocument.Load function is called. But also happens when going through the setting of table locations: [myTable.ApplyLogOnInfo(TmpTableLogOnInfo)
    The dll is called via COM interop and so i have checked "Register for COM interop".
    Simon@Sanderson

    1) Get to SP 3:
    for dev computer:
    https://smpdl.sap-ag.de/~sapidp/012002523100007123572010E/cr2008_sp3.exe
    Recompile the app after SP3 is applied.
    for SP3 runtime:
    MSI
    https://smpdl.sap-ag.de/~sapidp/012002523100007123592010E/cr2008sp3_redist.zip
    MSM
    https://smpdl.sap-ag.de/~sapidp/012002523100007123582010E/cr2008sp3_mm.zip
    (You will have to uninstall SP 2 runtime before installing SP 3 runtime)
    2) Do not use "Any CPU". CR2008 is only 32 bit anyhow so use 32 bit.
    3) Make sure you are using .Close and .Dispose once you are done with each report object
    - Ludek

  • Acrobat Reader Versions and saveAs, exportXFAdata Problems

    We use generate Forms with Reader Extension Save enabled.
    The forms are then opened within Acrobat Reader. In the onClose Event a Script called "saveXMLData" is called. This script is install in the javascript folder of the reader installation.
    The script :
    var saveXMLData = app.trustedFunction(function(doc)
         app.beginPriv();
         doc.saveAs({cPath:"/c/windows/temp/savedForm.pdf",
              bCopy: true,
              bPromptToOverwrite: false });
         doc.exportXFAData({
              cPath:"/c/windows/temp/savedForm.xml",
              bXDP:false
         app.endPriv();
         return;
    Using Acrobat Reader 7, eveything worked fine.
    Using Acrobat Reader 9 "saveAs" crashes the Application after the document is saved and the filled in Data is not saved.
    Without the saveAs function, at least the export File is generate but the data that where filled in are missing.
    Using Acrobat Reader X "saveAs" crashes the Application as well. Leavin out the saveAs function, the export File is generated as expected. Thus the filled in data values are saved.
    Using Acrobat X Pro everything works as with Acrobat Reader 7.
    Our Problem is that the customer uses Acrobat Reader 9. Are there expected incompatibilities with the different versions. Does anybody know any workarounds, settings?
    By the way disabling extended security does not help.
    Thanks
    Max

    It cannot be a problem of the installation, because at least Windows 7
    was a fresh install with nothing but Reader additionally installed.
    By the way, what do you mean by "risky", I followed straight the
    documentation from Adobe, where one is allowed to place function calls
    requiring a privileged context.
    Have you any better idea where to place the call to save? It must be
    called automatically, when the User closes the window, no additional
    interaction is possible.
    One other thing is the call to exportXFAData, have you any idea why
    there is a difference in behavior between reader version 7 / 10 and 9?
    I wrote that in version 9 the user entered data is missing.
    Am Donnerstag, den 21.07.2011, 05:53 -0600 schrieb try67:
    No, it doesn't work.
    Sorry, I don't have any ideas except for trying to repair the installation
    of Reader.
    However, placing code in the WillClose event is considered risky and should
    be avoided if there are alternatives available.
    >

  • Attempted to read or write protected memory error on reportdocument.load

    Reportdocument.load causes "System.AccessViolationException: Attempted to read or write protected memory" error.
    The error is not consistent. Sometimes a report will print. Sometimes a report will error.
    I am at a loss as to what to try.
    I have uninstall the app, reinstalled the app, uninstall and reinstalled .NET frameworks, Visual C++ runtime, etc.,
    reworked the code to try to capture the error. Nothing helps. Application crashes with Unhandled exception.
    Attempted to read or write to protected memory.
    Has anyone been able to resolve this issue?

    Hi Mary,
    What happens if you set your project to use 4.0 framework?
    Anything else in the Event Viewer to show an access violation?
    Have you tried updating the printer driver to one that is supported in the Framework? I find most legacy printers tend to use the old DEVMODE structure and not the Framework. Try using the printer off the Window CD rather than the Manufacturers driver.
    Is your app doing "Report Bursting"? In other words sending multiple reports one right after the other with no time between?
    Are you using any legacy UFL's? Try renaming u2lcom.dll if you are not using them. If you do you'll get an error in formula.
    Are you using try/catch in your code around each CR API? It may catch something more for you also.
    AND, can you try a C# project, some thing very simple also. I've of issues in VS VB that do not show up in other dev languages. Neither Microsoft or SAP can figure out what the cause is.
    Thank you
    Don
    Edited by: Don Williams on Feb 11, 2011 2:34 PM

  • Attempted to read or write protected memory followed by Load Report Failed

    After running OK for some time ASP.NET web application (VS 2008 .NET 3.5 with Crystal Reports included) running on MS WIN 2003 R2, SP2) will throw error when trying to create PDF crystal report. Error reads as follow:
    Attempted to read or write protected memory. This is often an indication that other memory is corrupt. -    at CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Close()     at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.InternalClose(Boolean bSetupForNextReport, Boolean bAutoClose)     at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Dispose(Boolean bDisposeManaged)     at System.ComponentModel.Component.Dispose()     at CrystalDecisions.CrystalReports.Engine.ReportDocument.InternalClose(Boolean bSetupForNextReport)     at CrystalDecisions.CrystalReports.Engine.ReportDocument.Close()
    After that every consecutive attempt to create another PDF crystal report will fail with fallowing error:
    Load report failed. -    at ... at System.Web.UI.WebControls.Button.OnClick(EventArgs e)     at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)     at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)     at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)     at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    Once Application pool is recycled, error goes away but comes back after while. It seems that recently the uptime is getting shorter.
    Anyone had similar experience, posible solution?
    Thanks in advance,
    Miro

    Hi Miro,
    Clean Temp folder of that machine.
    For testing export report to PDF format from designer do you face any issue?
    Try to export the report with following line of code :
            CrystalDecisions.CrystalReports.Engine.ReportDocument boReportDocument;
            CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument reportClientDoc;
            boReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            boReportDocument.Load(Server.MapPath("FinalActivityRpt.rpt"));
            reportClientDoc = boReportDocument.ReportClientDocument;
            boReportDocument.SetDatabaseLogon("sa", "sa");
            CrystalReportViewer1.ReportSource = boReportDocument;
            ExportOptions exportOptions = new ExportOptions();
            exportOptions.ExportFormatType = CrReportExportFormatEnum.crReportExportFormatPDF;
            PDFExportFormatOptions pdfOptions = new PDFExportFormatOptions();
            pdfOptions.StartPageNumber = 1;
            pdfOptions.EndPageNumber = 3;
            exportOptions.FormatOptions = pdfOptions;
            Response.AddHeader("Content-Disposition", "filename=" + "untiteled" + ".pdf");
            Response.ContentType = "application/pdf";
            Response.BinaryWrite((Byte[])reportClientDoc.ReportSource.Export(exportOptions, new         RequestContext()));
            Response.End();
    Regards,
    Shweta

  • Attempted to read or write protected memory problems

    Hi there, we are having some issues with ODP.net. every few days after our system has been used quite a lot we get the "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." errors.
    I can reproduce this just by launching some threads that all make some DB calls, and after a while (took over an hour in the case) we encounter the error. It it not just one DB call causing it, looking at the logs it does appear to only be calls to 'Get' data, but just about all of them have failed at some point.
    Yes we have upgraded to the latest version 11.1.0.6.20 and it still happens. Here are some stack traces, Oracle.DataAccess.Client.OpsSql.AllocSqlValCtx seems to be the most common in the stack traces though, others do occur.
    at Oracle.DataAccess.Client.OpsSql.AllocSqlValCtx(OpoSqlValCtx*& pOpoSqlValCtx) at Oracle.DataAccess.Client.OracleCommand.BuildCommandText() at Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior) at Oracle.DataAccess.Client.OracleCommand.ExecuteReader() at BUPA.HUGO.Common.DataAccessLayer.Database.StoredProcedures.ProspectSP.GetPersonProspectStoredProcedure.GetFullPersonDetailsDataReader(Int64 personId) in c:\Projects\CC.NETbuild_Hugo_Prod\Server\RF_Hugo_Services\Common\DataAccessLayer\Database\StoredProcedures\ProspectSP\GetPersonProspectStoredProcedure.cs:line 43
    Sometime the top of the stack is
    at Oracle.DataAccess.Client.OpsSql.CopySqlValCtx(OpoSqlValCtx* pOpoSqlValCtxSrc, OpoSqlValCtx*& pOpoSqlValCtxDst) at Oracle.DataAccess.Client.OracleParameter.PostBind_RefCursor(OracleConnection conn, OpoSqlValCtx* pOpoSqlValCtx) at Oracle.DataAccess.Client.OracleParameter.PostBind(OracleConnection conn, OpoSqlValCtx* pOpoSqlValCtx, Int32 arraySize) at Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior) at
    or
    at Oracle.DataAccess.Client.OpsDac.Read(IntPtr opsConCtx, IntPtr opsErrCtx, IntPtr opsSqlCtx, IntPtr& opsDacCtx, OpoSqlValCtx* pOpoSqlValCtx, OpoMetValCtx* pOpoMetValCtx, OpoDacValCtx* pOpoDacValCtx) at Oracle.DataAccess.Client.OracleDataReader.Read()
    Does anyone have any ideas? I saw some older post just asking people to try the new version (which we have). Any help on this matter would be great. We are having trouble figuring out if it is something we are not doing correctly or if there is a bug in ODP.NET.
    Thank you,
    Luke

    Hello,
    I've got exactly the same problem. We're using ODP.NET 10g R2 10.2.0.3.02 with RAC database. I found that this error only occurs after a Failover event.
    My application is .NET 3.0 WPF app.
    I'm able to reproduce this error at any time.
    Please have a look at some source code:
    //opening OracleConnection:
    theConn.Open();
    theConn.Failover += new OracleFailoverEventHandler(theConn_Failover);
    // handling the Failover event as stated in the docs:
    static FailoverReturnCode theConn_Failover(object sender, OracleFailoverEventArgs eventArgs)
    Logging.LogInfo("DB-FailoverEvent: " + eventArgs.FailoverEvent.ToString() + " - Type: " + eventArgs.FailoverType.ToString());
    switch (eventArgs.FailoverEvent)
    case FailoverEvent.Begin:
    Logging.LogInfo("FailoverEvent.Begin - Failover is starting");
    Logging.LogInfo("FailoverType = " + eventArgs.FailoverType.ToString());
    break; // TODO: might not be correct. Was : Exit Select
    case FailoverEvent.End:
    Logging.LogInfo("FailoverEvent.End - Failover was successful");
    break; // TODO: might not be correct. Was : Exit Select
    case FailoverEvent.Reauth:
    Logging.LogInfo("FailoverEvent.Reauth - User reauthenticated");
    break; // TODO: might not be correct. Was : Exit Select
    case FailoverEvent.Error:
    Logging.LogInfo("FailoverEvent.Error - Failover was unsuccessful");
    // Sleep for 3 sec and Retry
    Thread.Sleep(3000);
    return FailoverReturnCode.Retry;
    case FailoverEvent.Abort:
    Logging.LogInfo("FailoverEvent.Abort - Failover was unsuccessful");
    break; // TODO: might not be correct. Was : Exit Select
    default:
    Logging.LogInfo("Invalid FailoverEvent : " + eventArgs.FailoverEvent.ToString());
    break; // TODO: might not be correct. Was : Exit Select
    // comment following lines will not raise an error
    if (connect2DB())
    return FailoverReturnCode.Success;
    else
    return FailoverReturnCode.Retry;
    And here's the source for checking DB-connection:
    private static bool connect2DB()
    if (null == myConn)
    myConn = openOracleConnection();
    if (null == myConn)
    Thread.Sleep(5000);
    return false;
    try
    if ((myConn.State == ConnectionState.Broken) || (myConn.State == ConnectionState.Closed))
    myConn = openOracleConnection();
    String sql = "SELECT 1 FROM dual";
    using (OracleCommand cmd = new OracleCommand())
    cmd.Connection = myConn;
    cmd.CommandText = sql;
    cmd.CommandTimeout = 2;
    using (OracleDataReader dr = cmd.ExecuteReader())
    dr.Read();
    catch (Exception ex)
    Logging.LogError(ex);
    closeOracleConnection(myConn);
    myConn = openOracleConnection();
    setDBConnState();
    if (null != myConn)
    if ((myConn.State == ConnectionState.Broken) || (myConn.State == ConnectionState.Closed))
    return false;
    else
    return true;
    else
    return false;
    When I don't call "connect2DB()" in the failover event handler then everything is fine - otherwise oops the error occurs after approx. 14 hours after application runtime.
    Regards
    Sven

  • Multithreaded problem in read and write thread

    This is a producer consumer problem in a multi-threaded environment.
    Assume that i have multiple consumer (Multiple read threads) and a
    single producer(write thread).
    I have a common data structure (say an int variable), being read and written into.
    The write to the data sturcture happens occasionally (say at every 2 secs) but read happens contineously.
    Since the read operation is contineous and done by multiple threads, making the read method synchronized will add
    overhead(i.e read operation by one thread should not block the other read threads). But when ever write happens by
    the write thread, that time the read operations should not be allowed.
    Any ideas how to achive this ??

    If all you're doing is reading an int, then just use regular Java synchronization. You'll actually get a performance hit if you're doing simple read operations, as stated in the ReadWriteLock documentation:
    Whether or not a read-write lock will improve performance over the use of a mutual exclusion lock depends on the frequency that the data is read compared to being modified, the duration of the read and write operations, and the contention for the data - that is, the number of threads that will try to read or write the data at the same time. For example, a collection that is initially populated with data and thereafter infrequently modified, while being frequently searched (such as a directory of some kind) is an ideal candidate for the use of a read-write lock. However, if updates become frequent then the data spends most of its time being exclusively locked and there is little, if any increase in concurrency. Further, if the read operations are too short the overhead of the read-write lock implementation (which is inherently more complex than a mutual exclusion lock) can dominate the execution cost, particularly as many read-write lock implementations still serialize all threads through a small section of code. Ultimately, only profiling and measurement will establish whether the use of a read-write lock is suitable for your application.

  • Can I save to memory sticks for read and write access?

    I use M.S. Office for Mac to do my admin. I would be very grateful if anyone can help with my queries.
    I want to save work to media that allows me read and write access. Saving to discs (of any type) does not allow any editing.
    1. If I save to a memory stick will I be able to save and update my work when I want to?
    Also;
    2. Would a memory stick have to be formatted with to be suitable for Mac?
    3.If the memory stick can be used for the purpose, I want to encrypt it; how would I do this please?
    4. Would encrypting place a limit on the capacity of the memory stick that can be used, e.g.  I have a choice, including 8Gb and 16Gb.
    5. I have heard that passwords can be created by Mac; what is the method for doing this please?
    Many thanks for in advance.

    There is terminology here I am unfamiliar with. I feel I have embarked upon a complex path.
    I do not know what HFS+ is.
    HFS+ is the Mac OS X file system.  Hierarchical File System Plus (Plus as it used to be HFS, but then they improved it and said +)
    By default a USB flash drive generally comes formatted with FAT (from the Microsoft MS-DOS days, but is a universal format - it might come with FAT32 or exFAT as well - still from Microsoft).  Mac OS X can read/write these, HOWEVER, its FileVault whole disk encryption is only designed to work with HFS+, which is why I mentioned it.
    Applications -> Utilities -> Disk Utility can be used to reformat a disk, USB Flash drive, etc...  NOTE:  reformatting does erase everything on a disk, so keep that in mind.
    What is the difference between File Vault and .dmg in disk utilities?
    FileVault is whole disk encryption.  Everything on the disk is encrypted. and you need to enter the password just to mount the device.
    A .dmg file is a regular file that happens to contain a file system inside of it.  When you double click on the .dmg file, Mac OS X will mount the file system inside as if it was a disk.  If the .dmg file is encrypted, then you will be prompted for the password before Mac OS X will mount it.  A .dmg is just a container for a file system.  Inside that contain is a full file system with files and directories just like any other file system.
    You can create read only .dmg files, you can create read/write, you can create sparse (you declare the maximum side, but the initial size of the .dmg is small and will grow to the maximum size as you add things to the .dmg, you can create encrypted .dmg.
    Since a .dmg is just a file with no special attributes on the outside, it can be copied around.  You can copy it over the network, you can store it in the cloud, you can put it on a USB Flash drive, you can put it on an external disk, etc...
    If the device you put it can be mounted by Mac OS X, then you can double-click on the .dmg and it will mount the file system inside the .dmg and you will be able to access the files in the .dmg
    This even includes USB Flash drives that use the FAT format family.  But you existing external disks can be used for that as well.
    If I used an external hard drive for the purpose I have in mind, would the  disk .dmg utility allow me to access folders and files for editing or should I approach the task in a different way?  I would still wish to encrypt.
    As I said above, the .dmg is a full file system where you can store files and folders inside a .dmg container file.  And you can encrypt the .dmg so it is secure.

  • Problem with air read and write smb shared directory of file

    hi, everyone.
    I'm want to access smb directory of file,And to read and
    write operation, I would like to ask how I should do?
    Thanks!

    You can't access any OS facility nor execute arbitrary command.
    So the best solution is to mount samba directory BEFORE run your AIR application; you eventually can create a script that mount samba (and asks password) and then run you AIR application.
    see
    http://www.mikechambers.com/blog/2008/01/17/commandproxy-net-air-integration-proof-of-conc ept/
    for a more complex solution.

  • My DVD/CD-ROM and floppy disk drives can't read or write contents

    When I check through the computor it says verything is working. I have some CD's I wrote data and files to with this computor but for some reason it's showing me that there's nothing on the floppy's or the CD's.
    Mined you I have another computer and its able to see, write, save, to these same Floppy's or CD's.
    It's also telling me to load the CD when its already in the RW devices in my computer.
    I just reloaded everything on to a new hard drive in April, I used the DVD/CD-RW and everything was fine.
    My model is Satellite 2415 S205. I have reloaded Drivers. What else can I do? I refuse to believe the RW/DVD and the "A"  went bad at the same time.

    It sounds like you may have multiple problems, but none of them are likely to be caused by malware.
    First, the internet-related issues may be related to adware or a network compromise. I tend to lean more towards the latter, based on your description of the problem. See:
    http://www.adwaremedic.com/kb/baddns.php
    http://www.adwaremedic.com/kb/hackedrouter.php
    If investigation shows that this is not a network-specific issue, then it's probably adware. See my Adware Removal Guide for help finding and removing it. Note that you mention AdBlock as if it should have prevented this, but it's important to understand that ad blockers do not protect you against adware in any way. Neither would any kind of anti-virus software, which often doesn't detect adware.
    As for the other issues, it sounds like you've got some serious corruption. I would be inclined to say it sounds like a failing drive, except it sounds like you just got it replaced. How did you get all your files back after the new drive was installed?
    (Fair disclosure: I may receive compensation from links to my sites, TheSafeMac.com and AdwareMedic.com, in the form of buttons allowing for donations. Donations are not required to use my site or software.)

  • Loading and Saving problem in 2D space based rpg

    I am implementing a system in which the game saves the offset of the default position of an object in space and the object's position when the game is saved and applying that to the objects when the game is loaded. I get a strange problem however where every other undock after loading the game is far far away in space. I think it has something to do with the saved position of the object you docked with. Here is the code involved in loading the game (it just calls IO.java via dataAgent and gets data from a file)
    public void loadGame() throws FileNotFoundException, IOException {
            //load the game
            String[] tmpData = null;
            tmpData = dataAgent.loadGame();
            //interpet the data
            hud.currentDockedCelestialObject = Integer.parseInt(tmpData[0]) - 1;
            player.currentWallet = Integer.parseInt(tmpData[1]) - 1;
            player.currentSolarSystem = space[hud.currentDockedCelestialObject].solar;
            hud.renderMode = 1;
            hud.player = player;
            hud.space = space;
            hud.dPressed = true; //tell HUD we are docked at something
            //now we need to determine the position of all the celestial objects based on the saved position of the object in question
            int tmpx = Integer.parseInt(tmpData[2]) - 1;
            int tmpy = Integer.parseInt(tmpData[3]) - 1;
            //compare it to the docked celestial
            int changex = space[hud.currentDockedCelestialObject].positionX - tmpx;
            int changey = space[hud.currentDockedCelestialObject].positionY - tmpy;
            //apply the offset to all the objects in the current solar system
            for (int i = 0; i < space.length; i++) {
                if (space.solar.matches(player.currentSolarSystem)) {
    space[i].positionX += changex;
    space[i].positionY += changey;
    //now we need to load the ship type
    player.ship.type = Integer.parseInt(tmpData[4]);
    //configure the shields and hulls
    configureLoadedShip();
    //finish up
    hud.space = space;
    hud.player = player;
    Configureloadedship() just makes a call to apply the correct weapons and armor to the ship you have. Here is the saving code:public void saveGame() {
    //saves the game
    String[] toSave = new String[5];
    toSave[0] = "" + (hud.currentDockedCelestialObject + 1);
    toSave[1] = "" + (hud.player.currentWallet + 1);
    toSave[2] = "" + (space[hud.currentDockedCelestialObject].positionX);
    toSave[3] = "" + (space[hud.currentDockedCelestialObject].positionY);
    toSave[4] = "" + (hud.player.ship.type);
    try {
    dataAgent.saveGame(toSave);
    } catch (IOException ex) {
    Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    Adding and subtracting 1 durring load and save solved the problem of the java file reader skipping the 0 values in the first few lines of the saved game file.
    The game is loaded when the game starts and saved when you dock.
    Ty in advance for your help.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    public String[] loadGame() throws FileNotFoundException, IOException /*should never be thrown*/ {
            String[] toReturn = null;
            //load the data
            FileReader read = new FileReader(data);
            BufferedReader buff = new BufferedReader(read);
            String tmp1 = "";
            String tmp2 = "";
            while((tmp1 = buff.readLine())!=null) {
                tmp2 = tmp2 + tmp1+"~";
            //break it into a usable form
            toReturn = tmp2.split("~");
            System.out.println(tmp2);
            return toReturn;
        }and
    public void saveGame(String[] toSave) throws IOException {
            FileWriter write = new FileWriter(data);
            BufferedWriter buff = new BufferedWriter(write);
            //clear the old file
            data.delete();
            data.createNewFile();
            //zap the data to the file
            for(int i = 0; i < toSave.length; i++) {
                buff.write(toSave);
    buff.newLine();
    //write
    buff.flush();
    }They are basically just buffered readers and writers.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for

  • Download button not working in cloud?

    I have just uninstalled all my adobe programs to reinstall them into my D drive. However, I am unable to download any thing as the download buttond does nothing when I press it. What have i done wrong?

  • Valuation Currency not posting Group Currency equivalent

    Hi FSCM Experts, Can you help with this query please? We are activating FSCM FX and Hedge Management components. We have maintained the Valution Currency as EUR for the company code. The company code has Local Company Code currency of EUR.  When the

  • I keep getting this annoying "hum" whenever I record and play back!

    I'm using the latest iMac desktop, w/my Motif 7... connected through an EDIROL interface Model UA-1EX. Whenever I record/playback there is this "hum" that I can't get remove, whether I select "monitor on or off!" But I'm also using my ALTEC LANSING c

  • Question about returning old hubs etc. to BT

    Sorry if this isn't quite the right place to post this message, but I'm not sure where else to do so. I have a number of old BT hubs and hub phones that I want to dispose of. I'm aware that I can request kit return bags from BT but given the quite si

  • Photodeluxe Business Edition 1.0/1.1

    I guess it's time to move past PBE 1.0/1.1, , so is Photoshop Elements 12 a good choice? 1. I especially want that great Clone Tool 2. Also, the ability to  resize a document/photo that results in the exact sized print. 3. And, the ability to overlay