Store a HashMap in a file

Hi,
I have information in a HashMap which I need to save between executions. The keys are Strings and the values are Longs.
Is there some function to save all this information to a file? Or do I need to make it myself?

HashMap implements the Serializable interface. You can use serialization mechanism to store/retrieve the state of your HashMap.

Similar Messages

  • How to store the data of a file into an ArrayList?

    Hi! everyone.
    I want to know
    if I have a File, and the data in the file are type int, type String...
    And I have a ArrayList which is of type Question
    How do I store the data of that file into the ArrayList
    I tried to use the while loop(use the hasNextLine() to read the data line by line)
    But I cannot add data which are not of type Question to the ArrayList.
    Can you tell me what I should do, please?
    I also wonder that
    The data of the file are of many types, but when I try to read it with the nextLine(), the data all turn out to be of type String. Why?
    Thank you.
    Edited by: Terry001 on Apr 30, 2008 1:13 PM

    No, a line in the file is just part of a question
    The format of the file is like this:
    *<question type code>                    :     String*
    *<question point value>                    :     int*
    *<question category>                         :     String*
    *<question difficulty level>               :     int*
    *<question text>                              :     String*
    *<question correct answer>               :     String*
    *<optional question-specific data>     :     String*
    *<question terminator>                    :     String*
    And here is an example
    TF //TrueFalseQuestion
    5 //points value
    None //category
    3 //difficulty level
    The capital of the United States is Washington, D.C. //question text
    True // answer
    *** //quetion terminator
    I created an ArrayList in the Test class:
    private ArrayList<Question> questions; // Create inside constructor
        public Test (String name, String instr)
            testName = name;
            scoreEarned = 0;
            scorePossible = 0;
            instructions = instr;
            questions = new ArrayList<Question>(); //[MAX_NUMBER_OF_QUESTIONS];
        }And I tried to use the following method to store the data of the file to the ArrayList
    // This method loads a set of questions from a plain text file
        public void loadQuestionsFromFile(String fileName) throws FileNotFoundException
            try
                File fileReader = new File("input.txt");
                Scanner sc = new Scanner(fileReader);
                while (sc.hasNextLine())
                    // I don't know how to pass the data I got from the nextLine() method to the ArrayList because they are of different type
            catch (FileNotFoundException a)
                System.out.println(a);
        }    As all you said, I should create an Question object in the while loop
    Question temp = new Question ();But I have no idea how to pass the int and String to the Question object.
    Thank you

  • How can I store and retrieve a Word file after it's been converted to a pdf?

    How do I store and retrieve a Word file after it's been converted to an PDF?  My file has been trapped in PDF"hell" assigned to a folder that cannot be opened or read, but when deleted, also deletes the original Word file...

    I think we need some more info here like, how are you converting to PDF. This is the Reader forum and it doesn't convert files to PDF.

  • Store and Display doc/pdf files in the database using Forms

    Hi all,
    How can i store and display doc/pdf files in the database using Forms 10g?.
    Arif

    How to get up and running with WebUtil 1.06 included with Oracle Developer Suite 10.1.2.0.2 on a win32 platform
    Solution
    Assuming a fresh "Complete" install of Oracle Developer Suite 10.1.2.0.2,
    here are steps to get a small test form running, using WebUtil 1.06.
    Note: [OraHome] is used as an alias for your real oDS ORACLE_HOME.
    Feel free to copy this note to a text editor, and do a global find/replace on
    [OraHome] with your actual value (no trailing slash). Then it is easy to
    copy/paste actual commands to be executed from the note copy.
    1) Download http://prdownloads.sourceforge.net/jacob-project/jacob_18.zip
      and extract to a temporary staging area. Do not attempt to use 1.7 or 1.9.
    2) Copy or move jacob.jar and jacob.dll
      [JacobStage] is the folder where you extracted Jacob, and will end in ...\jacob_18
         cd [JacobStage]
         copy jacob.jar [OraHome]\forms\java\.
         copy jacob.dll [OraHome]\forms\webutil\.
      The Jacob staging area is no longer needed, and may be deleted.
    3) Sign frmwebutil.jar and jacob.jar
      Open a DOS command prompt.
      Add [OraHome]\jdk\bin to the PATH:
         set PATH=[OraHome]\jdk\bin;%PATH%
      Sign the files, and check the output for success:
         [OraHome]\forms\webutil\sign_webutil [OraHome]\forms\java\frmwebutil.jar
         [OraHome]\forms\webutil\sign_webutil [OraHome]\forms\java\jacob.jar
    4) If you already have a schema in your RDBMS which contains the WebUtil stored code,
      you may skip this step. Otherwise,
      Create a schema to hold the WebUtil stored code, and privileges needed to
      connect and create a stored package. Schema name "WEBUTIL" is recommended
      for no reason other than consistency over the user base.
      Open [OraHome]\forms\create_webutil_db.sql in a text editor, and delete or comment
      out the EXIT statement, to be able to see whether the objects were created witout
      errors.
      Start SQL*Plus as SYSTEM, and issue:
         CREATE USER webutil IDENTIFIED BY [password]
         DEFAULT TABLESPACE users
         TEMPORARY TABLESPACE temp;
         GRANT CONNECT, CREATE PROCEDURE, CREATE PUBLIC SYNONYM TO webutil;
         CONNECT webutil/[password]@[connectstring]
         @[OraHome]\forms\create_webutil_db.sql
         -- Inspect SQL*Plus output for errors, and then
         CREATE PUBLIC SYNONYM webutil_db FOR webutil.webutil_db;
      Reconnect as SYSTEM, and issue:
         grant execute on webutil_db to public;
    5) Modify [OraHome]\forms\server\default.env, and append [OraHome]\jdk\jre\lib\rt.jar
      to the CLASSPATH entry.
    6) Start the OC4J instance
    7) Start Forms Builder and connect to a schema in the RDBMS used in step (4).
      Open webutil.pll, do a "Compile ALL" (shift-Control-K), and generate to PLX (Control-T).
      It is important to generate the PLX, to avoid the FRM-40039 discussed in
      Note 303682.1
      If the PLX is not generated, the Webutil.pll library would have to be attached with
      full path information to all forms wishing to use WebUtil. This is NOT recommended.
    8) Create a new FMB.
      Open webutil.olb, and Subclass (not Copy) the Webutil object to the form.
      There is no need to Subclass the WebutilConfig object.
      Attach the Webutil.pll Library, and remove the path.
      Add an ON-LOGON trigger with the code
             NULL;
      to avoid having to connect to an RDBMS (optional).
      Create a new button on a new canvas, with the code
             show_webutil_information (TRUE);
      in a WHEN-BUTTON-PRESSED trigger.
      Compile the FMB to FMX, after doing a Compile-All (Shift-Control-K).
    9) Under Edit->Preferences->Runtime in Forms Builder, click on "Reset to Default" if
      the "Application Server URL" is empty.
      Then append "?config=webutil" at the end, so you end up with a URL of the form
          http://server:port/forms/frmservlet?config=webutil
    10) Run your form.sarah

  • How to create a file and store its contents into another file?

    Hi,
    I'm having some trouble trying to create a code where I have to to create a file and store its contents into another file?
    I read the API, but I'm not certain how this file thing works.
    Here's my code so far:
    public static void main(String[] args) throws Exception
              File file = new File("tasks.txt");
              if (file.exists())
                   System.out.println("File already exists");
                   System.exit(0);
              Scanner scan = new Scanner(System.in);
              Scanner scan2 = new Scanner(System.in);
              //Scans the input line by line
              scan.useDelimiter("\\n");
              //Scans the input by tabs
              scan2.useDelimiter("\\t");
              PrintWriter outputs = new PrintWriter("newtasks.txt");
              outputs.print("ok");
              outputs.println(3);
              outputs.close();
         }

    I managed to change my text into uppercase, but how do I store the uppercase content into another file.
    -So this is what I did so far, I took a text file and modified its strings to uppercase.
    -Now I need to put those modified strings into another text file, is there a way where I can do that with my current code?
    -I already tried printwriter, but it doesn't seem to work
    public static void main(String[] args)throws IOException
              //Task[] oneHundredTasks = new Task[100];
              String uppercase;
              String combine;
              Scanner scan = null;
              FileInputStream in = null;
            FileOutputStream out = null;
            PrintWriter output = null;
            try
                 scan = new Scanner(new BufferedReader(new FileReader("tasks.txt")));
                 scan.useDelimiter("\\n");
                 scan.useDelimiter("\\t");
                while (scan.hasNext())
                     if(!scan.hasNext())
                          scan.next();
                     combine = scan.next();
                     uppercase = combine.toUpperCase();
                     System.out.println(uppercase);
            finally
                if (scan != null)
                    scan.close();
            //The program will try the input and output files
            try
                 in = new FileInputStream("tasks.txt");
                out = new FileOutputStream("newtasks.txt");
                int c;
                //The number "-1" is used to indicate that it has reached the end of the stream.
                while ((c = in.read()) != -1)
                    out.write(c);
            finally
                if (in != null)
                    in.close();
                if (out != null)
                    out.close();
         }

  • Capture data and store it in a spreadsheet file

    Hello,
    I want to capture the waveform data from the scope TDS 744A for a specific period of time after a certain interval of time the trigger occurs, store it in a spreadsheet file and then plot the data points in the excel spreadsheet automatically. The trigger should occur as soon as the scope sees some input and after a specific period of time the data is captured and ploted on excel spreadsheet. Can you help me to do this.

    I'm sorry that I don't hav experience with your specific scope, but in general the GPIB commands mirror the operation of the manual controls. If you know how to set up the triggering on the scope manually look for the GPIB commands that do the same things. If you are still having problems in a couple more day and no one is responding to this thread you might want to repost the scope-specific portion of the question being sure to mention "Tek 744" in the subject line. That will increase the likelihood of someone who knows that instrument spotting the problem.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Can I take my new MacBook Pro retina to an apple store for them to transfer files

    Can I take my new MacBook Pro retina to an apple store for them to transfer files from my PC? I am migrating from window 7. I was planning on doing myself but it looks like you need two thunderbolt to Ethernet adapters and two Ethernet cables? What is the best way to transfer? I live in a rural area and think maybe wirelessly may not be the best way? Thanks for any assistance!

    Can I use my back up from my PC to transfer? I just backed up my PC to WD My Book. Will that work?
    Probably will work fine. It's worth a try and won't do any harm. 
    http://support.apple.com/kb/ht2518
    What you can transfer to your Mac depends on the files.
    Photo files (.jpg .tiff etc) fine
    Music files - some may need conversion software to be used in iTunes (unless you had iTunes on your PC) but free converters are there
    Video files - ditto, some will work in iMovie, others may need converting to work
    Text - Pages will read .doc and .docx files.  Most Word processing files/spreadsheet files/presentation files can be read in iWork but if not, can use Open Office or Libre Office (both free downloads)
    Windows programs (eg those with a .exe suffix) won't work on a Mac without installing Windows (e.g. via BootCamp).

  • Don't know how to store/show image or pdf files easily in apex app

    Hi,
    I always want to put a blob column in my table and store some images or pdf files, like drawings for an item, but I found it hard to do, I have viewed the sample app by apex 4.0, but I cannot understand the code.
    Is there a simple and intuitive way of storing/showing pdf files in an apex app?
    I wish Oracle could make an easier wizard for apex on that issue.
    just make storing a file as simple as in MS access, or email attachment, etc.
    no headache coding involved.
    that will be great!
    that will also do Oracle good, since images will use up a lot of spaces, maybe Xe won't be enough, the will consider an upgrade.

    Yawei,
    there is a chapter about BLOB support in the application builder users guide: http://download.oracle.com/docs/cd/E17556_01/doc/user.40/e15517/advnc.htm#BCGGJHEF
    Maybe this helps for a start, even if it isn't as easy as in MsAccess but this may be due to the fact that APEX is a web application and Access a rich client.
    brgds,
    Peter
    Blog: http://www.oracle-and-apex.com
    ApexLib: http://apexlib.oracleapex.info
    BuilderPlugin: http://builderplugin.oracleapex.info
    Work: http://www.click-click.at

  • I have a 2tb time capsule wondering how to store a lot of my files and photos on it to free up some space on my hard drive on my iMac

    i have a 2tb time capsule wondering how to store a lot of my files and photos on it to free up some space on my hard drive on my iMac

    For iMac please use USB or even better a FW800 or if you can afford it, a thunderbolt drive.. on your 2011 Mac.
    Time Capsule is not a suitable place to store your files.
    1. You will have no backup.
    2. TC cannot back itself up, nor can Time Machine backup network drives.
    3. Apple says specifically of iphoto not to store library on network drive.
    iphoto network no no.
    http://support.apple.com/kb/HT1198
    It's recommended that you store your iPhoto library on a locally mounted hard drive. Storing your iPhoto library on a network share can lead to poor performance, data corruption, or data loss.
    https://discussions.apple.com/thread/6692100
    4. Other libraries may not corrupt but will run very slowly. iTunes for example.
    Please purchase the fastest drive out of the external ports you have available.. usb2 although the slowest is still faster than TC over gigabit. It is also more reliable. TC are not a noted reliable storage drive. It is designed as a backup location for TM files.

  • Does apple store the .mp3 and other files I've purchased 'in the cloud'?

    Does apple store the .mp3 and other files I've purchased 'in the cloud'?  I had to restore my PC and forgot to back them up.  If not, I assume I would potentially need to purchase them again, right?  Please help.
    THIS IS REGARDING THE iTUNES Client Application V10.9.
    Thank You,
    The Technology Diva

    ''rajkumar05 [[#question-1049891|said]]''
    <blockquote>
    there is a problem with the firefox browser in my firefox os 1.3 intex cloud fx since i am not able to download any files using it.
    there are no other browsing application in the marketplace to, so help is required
    thanks.
    </blockquote>
    Hello Rajkumar,
    You can easily download media file. Follow these instructions: [http://mzl.la/1xKvGNs]

  • Store oracle table into flat file

    Hello,
    How to store oracle table into flat file with comma ( , ) delimiter.
    Thanx
    Murali

    set echo off feedback off termout off heading off pages 0
    spool path/filename
    select cola||','||colb||';'||colc ...
    from tablea;
    spool off

  • Is it possible to store script settings with InDesign file?

    Hi,
    I have some crazy idea: is it possible to store script settings with InDesign file?
    In that case scripters will be able to store those settings with file, and when script runs - it can check if those setting exists - if so - script can run without showing dialogue with parameters... (as all necessary parameters stored with indesign file), and of course we can force InDesign to show script parameters dialogue if we run it with alt/option key pressed while running this script. Maybe even different scripts will be able to share those settings and interact with each other.. we will be able to have settings that will be saved with file, or temp settings for current document or session (till InDesign is closed). With eventListeners and startup scripts we will be able to do scripts that would be able to check for updates, and automatically execute when we placing images and text, and so on.. this can be a whole InDesign scripting framework, that allow to write scripts that will use same libraries and ui so we don't have to write everything from scratch everytime and just included required libs..
    so here is 2 main questions for now:
    1) is it possible to store script settings with .indd file
    2) who is intrested in creation InDesign scripting framework (because this only makes sense if many people will use it)
    PS: I know that it's possible to store settings in external file, but this time I'm interested only for saving params with .indd

    Ok, here is the labels parser I end with, actually it works extremely fast!
    Thanks again, Harbs!
    var labels = GetDocLabels(app.documents[0]);
    function GetDocLabels(doc)
        var idmlFile = File(Folder.temp + "/temp.idml"); 
        doc.exportFile(ExportFormat.INDESIGN_MARKUP,idmlFile); // asynchronousExportFile works, but script fails as it try to execute before file fully exported
        var folder = Folder(Folder.temp + "/temp_idml"); 
        app.unpackageUCF(idmlFile,folder); 
        var designMap = File(folder + "/designmap.xml"); 
        var valuePairs = GetValuePairs(designMap); 
        return valuePairs;    
    function GetValuePairs(file)
        file.open("r");  
        var contents = file.read();  
        file.close();   
        var contXML = XML(contents);
        var vals = {};
        for each(var pair in contXML..KeyValuePair)
            vals[[email protected]()] = [email protected]();       
        return vals;  
    //> START of DELETE FOLDER Function
    function deleteFolder(path)
        removeFolder = path; // path to folder that need to be removed
        filesToRemove = removeFolder.getFiles();
        for(i = 0; i < filesToRemove.length; i++)
            try
                innerFolders = filesToRemove[i].getFiles();
                if(innerFolders.length >= 1)
                    for(f = 0; f < innerFolders.length; f++)
                        innerFolders[f].remove()
            catch(e){}
            filesToRemove[i].remove(); // remove temp files once we done
        removeFolder.remove();
    }//< END of DELETE FOLDER function
    // remove temp files once we done
    deleteFolder(Folder(Folder.temp + "/temp_idml"));
    File(Folder.temp + "/temp.idml").remove();
    // DUMPER FUNCTIONS
    function dump(o)
        out = "";
        for (var p in o)
            out += p + ": " + o[p] + "\n";
        return(out);
    function alert_scroll (title, input)
       if (input instanceof Array)
           input = input.join ("\r");
       var w = new Window ("dialog", title);
       var list = w.add ("edittext", undefined, input, {multiline: true, scrolling: true});
       list.maximumSize.height = w.maximumSize.height-100;
       list.minimumSize.width = 550;
       w.add ("button", undefined, "Close", {name: "ok"});
       w.show ();
    alert_scroll ("Document Labels", dump(labels)); exit();

  • I want to initialize my MBpro end reinstall lino, but I purchased it from apple store and cancelled the installation file. If i try to download again it from appstore I couldn't...How I can do ? Please help me

    I want to initialize my MBpro end reinstall lino, but I purchased it from apple store and cancelled the installation file. If i try to download again it from appstore I couldn't...How I can do ? Please help me

    Thanks for the feedback. Now, before installing in, put a copy some place safe and you won't have to download it again, wasting bandwidth, time, and electricity. Why? Because the installer blows itself away during the installation—IMO, a braindead delivery system, copied from their iOS world, but totally unsuitable for computers.

  • Store a container in separate files

    Is it possible to store a container in separate files?

    For example: I want to have one container only with the name, tv_show. In tv_show, I have millions of documents. Everytime, when I access, my path would be "dbxml:/tv_show" (something like this).
    From what you are saying, does that mean I should create numbers of containers for the tv_show?
    1. What are the advantages of creating numbers of containers and disadvantages of it?
    2. Should I have the exactly the same documents across the different containers or I should separate them?
    3. If the answer for the previous question is "separate them", how should I know which documents are in what container(s)?
    4. Or, it is possible to have the only container, tv_show. When thousands of users try to update nodes, it won't reduce the "read-only" access speed for the other users?
    Please forgive me if those questions do not seem clear or seems dumb. I am pretty new to the sleepcat DB, and I am very curious about it.

  • I download songs directly to my iTouch due to a computer crash.  I am still running an old iOS system.  Just notice yesterday I cannot download albums any longer just songs to my iPod? I go to ITunes store.  Open a music file to download and it will give

    I download songs directly to my iTouch due to a computercrash.  I am still running an old iOS system.  Just notice yesterdayI cannot download albums any longer just songs to my iPod? I go to ITunesstore.  Open a music file to download and it will give me the opportunityto buy every song but the album and songs that go with the album only.  Thebutton is not accessible for an album purchases. Any assistance would behelpful.

    No one has had this issue? I go to Itunes store.  Open a music file to download and it will gives me the opprotunity to buy every song but the album and songs that go with the album only.  HELP

Maybe you are looking for

  • Need to configure output type for adobe form

    Hello All, I need to configure output type for Adobe Form thru NACE. What would be print program and how do I call my form from that program? and, what would be the FORM routine for that form in NACE? I'm little confused, Pls I need your help. Thanks

  • My Airport Express Disconnect From the Cable Every Few Minutes

    Hello, I have had an Airport Express for 3 years and it sometimes disconnects after a few minutes. Actually, it more looks like that the Airport crashes: the "PC Link" light on the cable modem goes off, the Airport lights go off and I cannot find my

  • Will an Excel file retain formatted cells as a PDF using Acrobat XI Pro?

    Can Acrobat XI Pro create a form that will retain Excel formatted cells for filling in? Also, can it create a fillable cell that accepts an actual written signature?

  • Issue in accessing EJB from plain java

    Hi, I am new to OAS. I am using OAS 10.1.2. I want to access EJB which runs inside OAS, through a plain java program which runs from outside the OAS environment (standalone java program). I am confused on what to use. RMIInitialContextFactory or Appl

  • Display Attribute for Combo Box List of Value

    Hi all, I am wondering that if even for JDeveloper 12c we need to keep doing this work around https://blogs.oracle.com/adf/entry/combo_lov_how_to_display in order to display a meaningful attribute? Regards