How to save a properties object to a file / how to create a properties file

hi,
i am writing an application in which all the database and user information is stored in a properties object and is later retreived from it when a database connection or login etc is required.
i wanna know how can i save this object / write it to a file i.e. how do i create a properties file.
so that every time the application is run to create a new dbase etc the entire info regarding that will be stored in a new property file.

Load:
Properties p = new Properties();
FileInputStream in = new FileInputStream("db.properties");
p.load(p);
String username = p.getProperty("username");
String password = p.getProperty("password");
// ...Save:
String username = "user";
String password = "pw";
Properties p = new Properties();
p.setProperty("username", username);
p.setProperty("password", password);
FileOutputStream out = new FileOutputStream("db.properties");
p.store(out, null); // null or a String header as second argumentThe file will look something like
username=user
password=pw

Similar Messages

  • How to save properly Smart Object?

    Hello!
    I've got a file where I have 2 groups of layers (SET1 SET2)  (the first one is duplicated and made -100% (minus 100%)  width - which effects with horrizontal mirror of the first one). SET1 have texts, and as you may guess the mirrored groups of layers (SET2) has texts mirrored which I need to make readible (revert them back). That's why I made text layers as Smart Object and when I open this object I can rotate text back, but saving the Smart Object and returning back to the project gives me proper text on SET2 but rotated again SET1. I guess the Smart Object's in both sets are somehow related to each other. Every time I change something in one make an impact on the second. I noticed that even I save my Smart Object with some new name, to the directory I created for the project, it doesn't seem project choose that one in the project directory, but one from TEMP folder in windows root system. I thought to name them separately and load them to loose that relativeness. But I try and I try I do not know how to do it, how to make them independent.
    Any ideas?
    Kindest Pawel
    //I had to use Smart Object as Layers are transformed with Perspecitve transform tool, and vector objects (like text) can not be perspective transformed...and I can not in fact rasterize those Smart Objects as the project is a template to edit by others. If I rasterize them anybody could not change text layers anymore...
    I am getting to be sure, that's immpossible:/

    omg, somehow I did it. It seems that 'New Smart Object by Copy' breaks that relativness, but I am not quite sure as I tried to did it before withou success. Anyway, I am on the track again:)
    Thanks for listening

  • How we could share a object from outer tag to inner tag in tag files jsp2.0

    could any buddy will help me on the tag files jsp 2.0 probs
    how could we share a object of any class instantiated in outer customtag's .tag file to inner customtag's .tag file??
    i highly required it ,pls try for me
    for example:-
    <xx:outertag tablename="customer" class="pack1.abc" type="pack1.abc"/>
    <yy:innertag custname="neeraj" custid="22"/>
    i need an object 'customer'of class 'pack1.abc'in innertag instantiated from outertag's .tag file
    thanks

    the actul code of example is :-
    <xx:outertag tablename="customer" class="abc" package="pack1">
    <yy:innertag custname="gdgd" custid="11">
    </yy:innertag>
    </xx:outertag>
    thanks

  • How can I set Metronome to be OFF by default, besides creating a template file?

    Default setting for the Metronome was always OFF until I upgraded to iLife '11.
    From an archived thread on this topic, I was reminded of the technique of creating a template file to open with instead of "Create a New File", but that's a hassle to remember and find. And you have to remember to "Save as..." as soon as you get started.

    The Metronome is on every time I open any of my previous files, even after I turn it off. The next time I open the file, it's on again.  Impossible to stop that?
    If the answer is "no", then this is a BUG in this version of GarageBand.  Can't Apple developers correct that and issue an update?

  • Outlook Add-In Mail Item How to save the mail item (which is in compose mode) as a .msg file in non editable form?

    Hello,
    I am working on an outlook add-in where I have a custom button on the ribbon tab of compose mail item.
    My requirement is to save the mail item currently being composed as a .msg file at a predefined location on click of my custom "Save" button. I am able to do it using "mailItem.SaveAs(...)".
    But my problem is, when I open the .msg file in outlook, it is opened in compose mode but I want to see it as a read-only item. For e.g. exactly the way it looks when I save it after it's sent.
    Could you share any ideas on how to achieve this?
    Thanks,
    Vinay
    -Vinay Pugalia
    If a post answers your question, please click "Mark As Answer" on that post or
    "Vote as Helpful".
    Web : Inkey Solutions
    Blog : My Blog
    Email : Vinay Pugalia

    Strictly speaking you need to *remove* the MSGFLAG_UNSENT bit (=8), not set the MSGFLAG_READ bit, so setting the PR_MESSAGE_FLAGS property to either 0 or 1 will work. Keep in mind that you can remove the MSGFLAG_UNSENT bit only before the message
    is saved for the very first time. If you touch the bit after the message was saved, the message will stay unsent.
    Also note that this may not be what the user wants since the message will become read-only when reopened.
    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

  • How to save video clip in mp3 format?, How to save video clip in mp3 format?

    Hi
    Can someone advise on how I can save my video clip, currently in SD card, to a mp3 file? Thank you!

    Open the clip in MPEG Streamclip and use that to export the audio from it.
    (66807)

  • How to save an n-ary tree of nodes to and from an xml file

    Hello,
    I am trying to represent a n-ary tree of nodes in xml.
    More accurately, I am trying to save/instantiate a
    tree of nodes to-from an xml file.
    How do I represent the parent-child relationships?
    Java: (simplified)
    class Node {
    Arraylist childNodes;
    Node parent;
    XML:
    From what I have been learning about XML,
    DTD:
    <?xml version="1.0" ?>
    <!DOCTYPE acd
         <!ELEMENT Node (childNodes, parent)>
         <!ATTLIST Node id ID #REQUIRED>
         <!ELEMENT childNodes (Node*)>
         <!ELEMENT parent (Node?)>
    ]>
    Qs:
    1) How do I represent the relationships? What would
    normally be a reference in Java, how do I represent in
    XML?
    2) Do I use ID, IDREF? I have been trying to find some
    examples to learn how. i.e. Does the IDREF, ID
    automatically become an in-memory reference (or pointer)?
    3) Is it preferable to use XML schema?
    thanks,
    Anil Philip
    Olathe, KS
    for good news go to
    http://members.tripod.com/goodnewsforyou/goodnews.html

    I downloaded XML Spy and used it to correct my earlier schema.
    Qs:
    In the instance document xml file;
    1) How would one display the parent node?
    2) If a child has a reference to a parent node as in the schema below, how can one know that the references are the same?
    i.e. when the parent node is first declared and when it is referred to by the child.
    Perhaps this raises a larger question - how does XML handle recursive references?
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://juwo.com/acd" xmlns="http://juwo.com/acd" elementFormDefault="qualified" attributeFormDefault="unqualified">
         <xs:annotation>
              <xs:documentation>ACD nodes. juwo LLC 2005</xs:documentation>
         </xs:annotation>
         <xs:complexType name="Node">
              <xs:sequence>
                   <xs:element name="parent" type="Node" minOccurs="0"/>
                   <!-- Node[] childNodes -->
                   <xs:element name="childNodes" type="ListOfNodes"/>
                   <!-- String data -->
                   <xs:element name="data" type="xs:string"/>
              </xs:sequence>
              <!-- Node parent -->
         </xs:complexType>
         <xs:complexType name="ListOfNodes">
              <xs:sequence>
                   <xs:element name="i" type="Node" minOccurs="0" maxOccurs="unbounded"/>
              </xs:sequence>
         </xs:complexType>
    </xs:schema>

  • How to save a Windows 7 PSE video project to a .MP4 or .MOV file format?

    I've created a pan & zoom video slide show with PSE 8 and saved it to a WMF file for use by my church.  However, they recently switched over to using a MAC for presentations.   Does PSE 13 allow you to save video projects as MP4 or MOV files suitable for Apple platforms?  I know about free malware like Format Factory.  I uses that once and learned my lesson.  I'm hoping that the PSE 13 is friendlier to Apple formats.  Yea or nay?

    You need to ask this question in Premier Elements forum at this link:
    <Premiere Elements>
    Good luck.

  • Custom component  - how to store java Properties object in ucm environment

    Hi Experts,
    I am developing a custom component.
    my custom component code is reading a properties file and load in Properties object. Everytime this custom Service is called, properties file is read from file system and new Properties Object is created.
    Is there any way to load the Properties object once and store somewhere in UCM context ? (just like we do in JSP using application object"
    thanks!!
    Edited by: user4884609 on Jul 12, 2010 3:01 PM

    I'd say there are quite a few ways how to do it, but many of them have nothing in common with UCM.
    - I'd opt for the only "UCM" way I' aware of: as a part of custom component you can create your own properties file (it's also called environment variables) as a part of your custom component. You can, then, easily read (and write?) properties from/to the file.
    - The first option could have disadvantage, if there are too many properties. In this case you could use Java serialization - it should be UCM independent
    - Another option is to create your properties in the database - it is a bit similar to the first option, but it's more robust. Plus, you may use features of the database if you want to have some additional logic in you properties.
    - Note that you can also create a static object, which could be initialized e.g during class load

  • How to alter user defined  objects in  oracle

    Hi all,
    Can any one tell me how to alter user defined objects in oracle .
    Thanks,
    P Prakash

    prakash wrote:
    Hi all,
    Can any one tell me how to alter user defined objects in oracle .
    DROP
    then
    CREATE
    Handle:      prakash
    Email:      [email protected]
    Status Level:      Newbie (80)
    Registered:      Feb 3, 2011
    Total Posts:      185
    Total Questions:      67 (65 unresolved)
    so many questions & so few answers.
    How SAD!
    Edited by: sb92075 on Sep 22, 2011 9:22 AM

  • How to save message when getting "email not responding"

    how to save message when getting "email not responding"

    How could you even know if you have a message if the email account isn't responding?
    Quit the mail app and reboot your iPad.
    Tap the home button once. Then tap the home button twice and the recents tray will appear at the bottom of the screen. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner of the mail icon. Tap the home button twice.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.

  • Authorizations in CRM 2007 - How to check missing authorization objects?

    Hi,
    In our project we are currently busy with the set up of authorizations.
    I did create the necessary PFCG and Business roles.
    For the PFCG roles, I did create all of them by copy of the standard SAP_CRM_UIU_FRAMEWORK so that the user can  access to the web layout.
    Now I need to give authorizations for other CRM objects, my question is: How can I see which objects are missing to displaying or creating activities in the new WEB Layout?
    In the old days we used the SU53 to check the authorization objects that were missing, how can we do it now in this new release? I tried it and didn't worked out.
    Thx
    Regards
    Hugo

    Hi,
    For report CRMD_UI_ROLE_PREPARE you have to input a business role - not a PFCG role. Are you doing that?
    Are you getting no results at all in ST01 or are all results just with return code 0?
    You have to remember to set a filter for your user in ST01 before activating the trace. Another thing to check is if you are using several application servers. I would imagine the trace has to be activated on the same application server as the Web UI. You can change the application sever in SM51.
    /Anders

  • How to divide big serialized object in parts to be able to save as Blob typ

    Hi,
    Actually i have serialize a big XML document object and want to save in a field of type Blob. As Blob size is 64k. So if the serialized object is greater than 64k. It gives me error of size.Can anybody tell how to break large serialized objects.
    I am using this code
    File f = new File("out.ser");
    FileInputStream fin = new FileInputStream(f);
    p = farCon.prepareStatement("insert into TeeColor values('3',?)");
    p.setBinaryStream(1, fin, f.length());
    p.executeUpdate();
    This code works fine if the size of out.ser file is less than 64k. But does not work for bigger sizes
    Please help me out
    Thanks

    Read your data from the file into a byte array, then extract 64K at a time into a smaller byte array, and use a ByteArrayInputStream for updating the database.

  • Reference to C# objects in TestStand - how to save and retreive them

    I am new to LabView and TestStand.
    I want to use 2 .NET objects in those applications
    In Labiew, I successfully created the objects, manipulate the functions through VIs and closed the references.
    While I could use the VIs for TestStand, I would rather use the DLL directly.
    I am able to create both objects in a sequence, but I have problems with the following:
      - I don't know how to save the reference to the object after the constructor is run.
        - is the object stored in Globlal variables? I tried 'RunState.Engine' but it does not work
      - I don't know how to get the reference back in the other steps where I want to reuse the object to invoke a method on.
      - Once I can do the above, I need to get it to work in the 'batch' or 'parallel' modes.
         I am using successfully the 'RunState.TestSockets.MyIndex' to select my testing resources,
         but I am still confuse as where the array of objects would be.
         Note that I already set the number of DUT <> 1 and I can create successfully my 2 objects in X instances.
    Thanks,
    Daniel Coupal

    dcoupal,
    Getting the reference to the object involves specifying that as a return value in one of your parameters when you specify the module for that action. Inside of the parameters table you can also save that return value as a local object reference and then use it later on in the sequence.
    Regarding your second question, I'm not sure what the array of objects is that you're referring to but this KB might be of some assistance.
    Message Edited by Jon M on 11-01-2006 12:44 PM
    Test Engineer - CTA

  • Dynamically built query on execution How to save the data in Object Type

    Hi,
    In pl/sql I am building and executing a query dynamically. How can I stored the output of the query in object type. I have defined the following object type and need to store the
    output of the query in it. Here is the Object Type I have
    CREATE OR REPLACE TYPE DEMO.FIRST_RECORDTYPE AS OBJECT(
    pkid NUMBER,
    pkname VARCHAR2(100);
    pkcity VARCHAR2(100);
    pkcounty VARCHAR2(100)
    CREATE OR REPLACE TYPE DEMO.FIRST_RECORDTYPETAB AS TABLE OF FIRST_RECORDTYPE;Here is the query generated at runtime and is inside a LOOP
    --I initialize my Object Type*
    data := new FIRST_RECORDTYPETAB();
    FOR some_cursor IN c_get_ids (username)
    LOOP
    x_context_count := x_context_count + 1;
    -- here I build the query dynamically and the same query generated is
    sql_query := 'SELECT pkid as pid ,pkname as pname,pkcity as pcity, pkcounty as pcounty FROM cities WHERE passed = <this value changes on every iteration of the cursor>'
    -- and now I need to execute the above query but need to store the output
    EXECUTE IMMEDIATE sql_query
    INTO *<I need to save the out put in the Type I defined>*
    END LOOP;
    How can I save the output of the dynamically built query in the Object Type. As I am looping so the type can have several records.
    Any help is appreciated.
    Thanks

    hai ,
    solution for Dynamically built query on execution How to save the data in Object Type.
    Step 1:(Object creation)
    SQL> ED
    Wrote file afiedt.buf
    1 Create Or Replace Type contract_details As Object(
    2 contract_number Varchar2(15),
    3 contrcat_branch Varchar2(15)
    4* );
    SQL> /
    Type created.
    Step 2:(table creation with object)
    SQL> Create Table contract_dtls(Id Number,contract contract_details)
    2 /
    Table created.
    Step 3:(execution Of procedure to insert the dynamic ouput into object types):
    Declare
    LV_V_SQL_QUERY Varchar2(4000);
    LV_N_CURSOR Integer;
    LV_N_EXECUTE_CURSOR Integer;
    LV_V_CONTRACT_BR Varchar2(15) := 'TNW'; -- change the branch name by making this as input parameter for a procedure or function
    OV_V_CONTRACT_NUMBER Varchar2(15);
    LV_V_CONTRACT_BRANCH Varchar2(15);
    Begin
    LV_V_SQL_QUERY := 'SELECT CONTRACT_NUMBER,CONTRACT_BRANCH FROM CC_CONTRACT_MASTER WHERE CONTRACT_BRANCH = '''||LV_V_CONTRACT_BR||'''';
    LV_N_CURSOR := Dbms_Sql.open_Cursor;
    Dbms_Sql.parse(LV_N_CURSOR,LV_V_SQL_QUERY,2);
    Dbms_Sql.define_Column(LV_N_CURSOR,1,OV_V_CONTRACT_NUMBER,15);
    Dbms_Sql.define_Column(LV_N_CURSOR,2,LV_V_CONTRACT_BRANCH,15);
    LV_N_EXECUTE_CURSOR := Dbms_Sql.Execute(LV_N_CURSOR);
    Loop
    Exit When Dbms_Sql.fetch_Rows (LV_N_CURSOR)= 0;
    Dbms_Sql.column_Value(LV_N_CURSOR,1,OV_V_CONTRACT_NUMBER);
    Dbms_Sql.column_Value(LV_N_CURSOR,2,LV_V_CONTRACT_BRANCH);
    Dbms_Output.put_Line('CONTRACT_BRANCH--'||LV_V_CONTRACT_BRANCH);
    Dbms_Output.put_Line('CONTRACT_NUMBER--'||OV_V_CONTRACT_NUMBER);
    INSERT INTO contract_dtls VALUES(1,CONTRACT_DETAILS(OV_V_CONTRACT_NUMBER,LV_V_CONTRACT_BRANCH));
    End Loop;
    Dbms_Sql.close_Cursor (LV_N_CURSOR);
    COMMIT;
    Exception
    When Others Then
    Dbms_Output.put_Line('SQLERRM--'||Sqlerrm);
    Dbms_Output.put_Line('SQLERRM--'||Sqlcode);
    End;
    step 4:check the values are inseted in the object included table
    SELECT * FROM contract_dtls;
    Regards
    C.karukkuvel

Maybe you are looking for

  • Reporting Services for Microsoft SQL Server 2008 R2 (RTM) - 10.50.1617.0

    Hello, We are currently running: Microsoft SQL Server 2008 R2 (RTM) - 10.50.1617.0 (Intel X86)   Apr 22 2011 11:57:00   Copyright (c) Microsoft Corporation  Standard Edition on Windows NT 5.2 <X86> (Build 3790: Service Pack 2) (Hypervisor) We would l

  • Activation of open item management in G/L account

    Hello all, I have a G/L account with existing line items on it without open item management activated and the client wishes to activate open item management now. I have managed to activate the actual G/L account option, but my question is about the s

  • Pls urgent reply will be appreciated

    A form i enclosed in a jscrollpane doesnt print the full form. It only prints the part visible on the screen. I,ve done all the 2d tricks like clipping, setting my imageable area all as i can... pls urgent reply to this will be appreciated; i attach

  • How to get the loop sequence time (i) out of the while loop in the sub-vi to the main vi?

    I tried to search for the answer but no much luck.  My situation is that I used a sub-vi containing a while loop in my main vi. Now I need to see the while loop sequence number (i) from that sub-vi in my main vi.  In the sub-vi I have the indicator t

  • Get value of Table data in Event of Table maintaince generaor

    Hi Expert, I want content of table in event of table maintenance generator (Event 01 - Before Saving Data in Database). can you please tell me that how can i achieve this value of whole table in this event. Regards, Chintan Shah