Propblem with Properties class and .ini file !

Hello I have to read and write in a .ini file. I've got no problem, using a bit of code like this
Properties iniFile = new Properties();
String result="exception";
try{     
iniFile.load(new FileInputStream(path));
result = iniFile.getProperty("SrcPath","not found");     
catch(IOException e){}
finally{return result;}
it works correctly, but my problem is that my .ini file contain path like "SrcPath = e:\directory1\directory2"
And then in my result variable I get : "e:directory1directory2" all the slash are cutted by iniFile.load !!
And the problem is that I can not put "\\" in my ini file because it is used by other programs that need just one slash !!!!
Is anybody got an idea to get the right path "e:\directory1\directory2"
Thanks by advance Eric

1st question.
Properties props = new Properties();
     try{
          String uploadprop = "c:/yourinifile.ini";
          File file = new File(uploadprop);
     FileInputStream fis = new FileInputStream(file);
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          int character;
          while((character=fis.read()) != -1){
          baos.write(character);
          if((char)character == '\\')
               //write one more '\'
               baos.write(character);
          ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
          baos.close();
          //load bais
          props.load(bais);
          bais.close();
          fis.close();
          System.out.println(props.getProperty("dirname"));
     }catch(Exception e){
hope this helps
rishi

Similar Messages

  • .bat file and .ini file

    I have a batch file with the following contents, I need to substitute the paths \\folder\projectname\formatter\saxon8\ with a variable using .ini file. Could anyone please tell me how do I do this
    @echo off
    cls
    echo.
    set CP=\\folder\projectname\formatter\saxon8\saxon8-jdom.jar;\\folder\projectname\formatter\saxon8\saxon8-sql.jar;\\folder\projectname\formatter\saxon8\saxon8sa.jar;\\folder\projectname\formatter\saxon8\saxon-license.lic
    ...If the path of the needed files gets changed in future, the user need to change the path only in the .ini file and that should reflect in the .bat file.
    Message was edited by:
    Simmy
    Message was edited by:
    Simmy

    I am reading the INI file in my code whose value C:\\temp\\ is getting displayed in my Batch file, but I need to display only the keyword Path in my Batch file. Can you please tell me what modifications I need to do in my code.
    This is the contents of my INI file
    [INI file : user.ini]
    Path="C:\\temp\\"
    The following is my code
        public void createFile()
            try
                p = new Properties();
                p.load(new FileInputStream("D:/user.ini"));
                JarPath=p.getProperty("Path");
                p.list(System.out);
            catch(Exception e)
                System.out.println(e);
            File file1=new File("D:/temp/ps1.bat");
            BufferedWriter bw1;
            try
                bw1=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file1)));
                bw1.write("@echo off\n");
                bw1.write("cls\n");
                bw1.write("echo.\n");
                bw1.write("set CP="+JarPath+"saxon8-jdom.jar;"+JarPath+"saxon8-sql.jar;"+JarPath+"saxon8sa.jar;"+JarPath+"saxon-license.lic\n");
                bw1.flush();
            catch(IOException ioe)
                System.out.println("Error creating \"ps1.bat\". Process terminated.");
    Currently, the following is my Batch file contents
    @echo off
    cls
    echo.
    set CP=C:\temp\saxon8-jdom.jar;C:\temp\saxon8-sql.jar;C:\temp\saxon8sa.jar;C:\temp\saxon-license.lic
    But I need my Batch file to display
    @echo off
    cls
    echo.
    set CP=Path\saxon8-jdom.jar;Path\saxon8-sql.jar;Path\saxon8sa.jar;Path\saxon-license.lic

  • Where to put common classes and jar files

    hi,
    i want to put some classes and jar files in a common folder so that it can be accessed by other applications is there any way doing that.In tomcat server they have common and shared directories once any classes are into that folder they are being accessed easily ,but i am having problems with sun one .
    Regards
    Ameem Sami

    Did you find a solution for this? I'm having the same problem.
    Thanks,
    Tony

  • [svn:osmf:] 16580: Converted classes and project files to work in flex 3.5

    Revision: 16580
    Revision: 16580
    Author:   [email protected]
    Date:     2010-06-16 17:08:07 -0700 (Wed, 16 Jun 2010)
    Log Message:
    Converted classes and project files to work in flex 3.5
    Modified Paths:
        osmf/branches/zeri-certification/Test_Apps/FlexUnit4/.actionScriptProperties
        osmf/branches/zeri-certification/Test_Apps/MediaTests/.actionScriptProperties
        osmf/branches/zeri-certification/Test_Apps/MediaTests/html-template/history/history.js
        osmf/branches/zeri-certification/Test_Apps/MediaTests/html-template/index.template.html
        osmf/branches/zeri-certification/Test_Apps/MediaTests/src/InstructionsForm.mxml
        osmf/branches/zeri-certification/Test_Apps/MediaTests/src/MediaTests.mxml
        osmf/branches/zeri-certification/Test_Apps/MediaTests/src/ZeriTests.mxml
        osmf/branches/zeri-certification/Test_Apps/Zeri_Custom_Player/.actionScriptProperties
        osmf/branches/zeri-certification/Test_Apps/Zeri_Custom_Player/html-template/history/histo ry.js
        osmf/branches/zeri-certification/Test_Apps/Zeri_Custom_Player/html-template/index.templat e.html
        osmf/branches/zeri-certification/Test_Apps/Zeri_Custom_Player/src/Zeri_Custom_Player.mxml
        osmf/branches/zeri-certification/Test_Apps/Zeri_Custom_Player/src/comps/LogBuffer.mxml
    Added Paths:
        osmf/branches/zeri-certification/Test_Apps/MediaTests/html-template/AC_OETags.js
        osmf/branches/zeri-certification/Test_Apps/Zeri_Custom_Player/html-template/AC_OETags.js
    Removed Paths:
        osmf/branches/zeri-certification/Test_Apps/MediaTests/html-template/swfobject.js
        osmf/branches/zeri-certification/Test_Apps/Zeri_Custom_Player/html-template/swfobject.js

    Hi for anyone getting similar issues,
    the solution is described in http://forums.adobe.com/message/3302944#3302944
    This is not a bug.
    Arnoud

  • Part interchangeability with FFF class and FFFC - HERB material type

    Experts-
    Have you worked with Part interchangeability with FFF class and FFFC or HERB material type?
    I am looking for cross-reference functionality for interchangeable materials from maintenance/service perspective. We have users changing manufacturer's part number as and when needed and maintaining cross-reference via classification. Maintaining SAP part number and HERS is too much data maintenance, so we are looking for simple solution.
    We are in standard ECC 6.0. (No APO). I checked OSS 181764, but it doesn't help us in instructions for enhancement.
    If this needs activation for DIMP or A&D, do you know enhancement for this?
    Thanks for your help.
    RP

    Hi
    I have been involved with a client who is interested to know the implementation of FFF functionality. Can you share your experience  in a bit more details.
    The client is interested in using parts where multiple models are available in the market and few of them are interchangeable. They would like to purchase it as an asset and then manage the inventory as non valued material. How does it work throuh the APO for forecasting and demand planning functionalities.
    Thanks in advance.

  • Yosemite finder crashes with previewig .txt and other files

    Hello,
    under Yosemite  the Finder crashes with previewig .txt and other files.
    Is this just my problem? Help please.
    Thank you very much.
    Regards.

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad and start typing the name.
    Step 1
    For this step, the title of the Console window should be All Messages. If it isn't, select
              SYSTEM LOG QUERIES ▹ All Messages
    from the log list on the left. If you don't see that list, select
              View ▹ Show Log List
    from the menu bar at the top of the screen.
    In the top right corner of the Console window, there's a search box labeled Filter. Initially the words "String Matching" are shown in that box. Enter the name of the crashed application or process. For example, if Safari crashed, you would enter "Safari" (without the quotes.)
    Each message in the log begins with the date and time when it was entered. Select the messages from the time of the last crash, if any. Copy them to the Clipboard by pressing the key combination command-C. Paste into a reply to this message by pressing command-V.
    ☞ The log contains a vast amount of information, almost all of which is irrelevant to solving any particular problem. When posting a log extract, be selective. A few dozen lines are almost always more than enough.
    Please don't indiscriminately dump thousands of lines from the log into this discussion.
    Please don't post screenshots of log messages—post the text.
    ☞ Some private information, such as your name, may appear in the log. Anonymize before posting.
    Step 2
    In the Console window, select
              DIAGNOSTIC AND USAGE INFORMATION ▹ User Diagnostic Reports
    (not Diagnostic and Usage Messages) from the log list on the left. There is a disclosure triangle to the left of the list item. If the triangle is pointing to the right, click it so that it points down. You'll see a list of crash reports. The name of each report starts with the name of the process, and ends with ".crash". Select the most recent report related to the process in question. The contents of the report will appear on the right. Use copy and paste to post the entire contents—the text, not a screenshot.
    I know the report is long, maybe several hundred lines. Please post all of it anyway.
    If you don't see any reports listed, but you know there was a crash, you may have chosen Diagnostic and Usage Messages from the log list. Choose DIAGNOSTIC AND USAGE INFORMATION instead.
    In the interest of privacy, I suggest that, before posting, you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header of the report, if it’s present (it may not be.)
    Please don’t post other kinds of diagnostic report—they're very long and rarely helpful.

  • Java classes and MySql Files

    Hello,
    There is a way to distribute the Mysql db files with yout java application without need to install Mysql in the computer, like in access, you just copy the .mdb file with your java class and create a conection to it.
    Thank You

    No. If you want to do that you should just use Access. mySQL files will not work without the mySQL server.

  • Weblogic startup class and EAR file

    Hi,
    I am using WL 8.1.5.
    I have a weblogic starup class MyStartup that implements T3StartupDef. (it does not specify package).
    I jar-ed it. And I placed MyStartup.jar file into the MyEA.ear file. And I placed that into applications dir.
    With WL Console I defined the startup class and for the ClassName specified MyStartup.
    Yet I get the java.lang.ClassNotFoundException.
    I also have a Manifest.mf file with
    Class-Path: MyStartup.jar
    Please help me solve this problem, I literally don't know what to do next.
    MB

    Hi,
    thanks.
    This seems like a completely opposite method of the depplying startup class with weblogic console.
    Does my class still need to implement T3StartupDef?
    I get this exception. And my classnotfound is still there.
    Exception:weblogic.management.ApplicationException: startup.MyStartup
         at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.createContainer(SlaveDeployer.java:2484)
         at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.prepare(SlaveDeployer.java:2396)
         at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer.java:883)
         at weblogic.management.deploy.slave.SlaveDeployer.prepareDelta(SlaveDeployer.java:591)
         at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java:500)
         at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:25)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
    Regards,
    MB

  • Write message to Job log with message class and message number

    hi folk,
    When running a background job I'm able to write a message to the job log using the statement - Message "some text..." type 'I'.
    In the Job log I can see the message "some text.." with a "default" message class and message number (but in my report i don't specify any message ID) so I have no idea it comes from.
    Then I try to send a message where I specify the message class/number etc...using message id 'Z1' number 000 with "some text..." In the job log I now can see the "right" message class "Z1" and the number 000, but the message is empty?
    Please advice how to write a message with the message class and message number.
    Best regards
    LinhNg

    Hi Linh,
    How did you provide the text "Some message"? Did you hard code it or used a text element?
    Regards,
    Immanuel.

  • ABAP Objects with Workflows / Classes and Instances

    Hello,
    I am currently designing a workflow using an ABAP-Objects. So far I have been been able to get my Workflow to run with my class, but I have a couple of problems:
    - I am using the Function 'SAP_WAPI_START_WORKFLOW' to start other subflows, which enables me to decide which subflow to start at runtime. All of the subflows have standart importing-parameters in their containers, such as the key of my class. In each workflow I instantiate my class using a self-written method, which checks the table T_INSTANCES in my object, and then either returns the object reference to an existing instance or creates a new one. Obviously all of the subflows that I call from my main workflow should be able to find the instance. As far as I can see in their protocolls, this happens without any problems. The problem starts when I make changes to the instance. For example the changing of attributes (with setter methods) seems not to work. After the subflows are finished, in my main workflow, I do not see (with getter methods) any changes that has been made to the object. Is local persistence really limited to one workflow ?
    - My second problem is basically about the workflow container in workflow protocoll. In the same workflow, I can change the attributes of my object. Nevertheless, the protocoll always show the initial attribute, even though, my task with the getter-method returns the new value of the attribute.
    I appreciate any help and thanks a lot in advance.

    Hello Pauls,
    Thank you for your answer. I think we are misunderstanding each other. The problem occurs (I think) because my class is not a singleton class. Or am I mistaken ?
    When I directly start a subflow from my main workflow, then the instance that I have created in my main workflow is also visible to the subflow. As well as the static table which actually keeps track of the instances. So, in this case the subflows finds the instance and then can use the object as is.
    When I start a subflow from my main workflow using the function I mentioned above, then even though the same object key is used, there is a new instance. And the static table (I assume that you mean a static variable from type table, when you say "class table") is completely empty. In this case, my "new" instance is created which overwrites every attribute that I have set in the main workflow, before I started the subflow. More interestingly, my main workflow instantiates another new object, as soon as the subflow has finished. (I am using an event to wait for the subflow to finish.)
    On the other hand, I am not quite sure that I understood your approach with refresh and how it could help me. This method is not well documented anywhere, and all of the examples that I have found are about "leave it empty"
    As far as I understood, this method is called by the workflow between the steps, when an object is used. I slowly start to think that I need advanced information about Workflows and Memory Management.
    Thanks a lot again. Apparently, I am the only person who came across such a problem
    Greetz
    G.Fendoglu

  • Nested classes and separate files in Javadoc...

    Hello. I am writing an application, and it has several .java files, and some of the classes contained therein contain nested classes, for example
    ClassOne.java
    class ClassOne
    // stuff
       class innerClassOne
          //more stuff
    }ClassTwo.java
    class ClassTwo
    // stuff
       class innerClassTwo
          //more stuff
    }What I want to do is generate documentation like the online java documentation for my app, that is, documentation that will contain ALL the classes and nested classes involved, and link everything that comes in java already to the sun online java docs.
    I've figured out the -link command for javadoc, and I can make that work, but I've run into some other snags.
    1.) Javadoc isn't finding or documenting my nested classes, despite them being marked up. Google does not wish to help.
    2.) Some classes reference other classes of mine that aren't conatined in the same .java file, but do exist in their own .java files in the dame local directory. Javadoc does not like this, and gives errors.
    3.) Running javadoc on one file at a time overwrites the old file's documentation, thus I cannot seem to get an index.html javadoc file that links to all my classes, nor can I get the classes to link to each other.
    What do I need to do to fix these?

    So this means a nested static inner class CANNOT refer to its own instanced variables, like a normal static method, but CAN refer to its outer class instanced variables?No, it means that a static nested class cannot refer to instance variables of its enclosing class. Example:public class Foo {
        int i;
        static class Bar {
            int j = i; // WRONG! Bar class is static context
    }~

  • Working with forms, buttons and text files

    please am new to java am working on the project. please see sample below, can anyone tell me how i can get the button in form1 to open form2 and also how the information entered in the textfield can be written to a text file. THANKS
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Form1 extends JFrame
         static JFrame frame;
         static JPanel panel;
    JLabel label;
         JTextField text;
         JButton btn;
         GridBagLayout g;
    GridBagConstraints gbc;
         public Form1()
              label = new JLabel ("Label");
              gbc.gridx = 0;
    gbc.gridy = 1;
    g.setConstraints(label, gbc);
    panel.add(label);
              text = new JTextField();
    gbc.gridx= 1;
    gbc.gridy = 1;
    g.setConstraints(text, gbc);
    panel.add(text);
              btn = new JButton ("CONTINUE");
              gbc.gridx = 0;
              gbc.gridy = 2;
              g.setConstraints(btn, gbc);
              panel.add(btn);
    import java.awt.event.*;
    public class Form2 extends JFrame
         static JFrame frame;
         static JPanel panel;
    JLabel label;
         JTextField text;
         JButton btn;
         GridBagLayout g;
    GridBagConstraints gbc;
         public Form2()
              label = new JLabel ("Label2");
              gbc.gridx = 0;
    gbc.gridy = 1;
    g.setConstraints(label2, gbc);
    panel.add(label2);
              text2 = new JTextField();
    gbc.gridx= 1;
    gbc.gridy = 1;
    g.setConstraints(text2, gbc);
    panel.add(text2);
    }

    please am new to java am working on the project.
    please see sample below, can anyone tell me how i can
    get the button in form1 to open form2 For opening form2 from form1 you can add a actionListener to the button.When the button is pressed instantiate the other class and render it visible which i leave it to you to implement.
    and also how
    the information entered in the textfield can be
    written to a text file. THANKSUse getText ( ) method of JTextField to retrieve the text from it and then it's ordinary file io operations for which i guide you to the tutorials here
    http://java.sun.com/docs/books/tutorial/essential/io/index.html

  • How to burn a dvd with both Mac and Windows files

    I have a DVD that has both Mac and Windows formatted files. When the DVD is mounted only Mac formatted files show. I want to burn a DVD copy containing both formatted files. How do I do that? Thanks in advance.

    Correction! It is a CD and there are two partitions with Mac and Windows files.

  • How do I import an old home movie on DVD into iMovie with video_ts content and .vob files

    Hi, as a new mac user I would appreciate any help to use imovie to import an old home movie on DVD with movie_ts content and .vob

    You need to convert the VOB files in the TS-Folder of the DVD back to DV which iMovie is designed to handle. For that you need mpegStreamclip:
    http://www.squared5.com/svideo/mpeg-streamclip-mac.html
    which is free, but you must also have the  Apple mpeg2 plugin :
    http://store.apple.com/us/product/D2187Z/A/quicktime-mpeg-2-playback-component-f or-mac-os-x
    (unless you are running Lion in which case see below))
    which is a mere $20.
    Another possibility is to use DVDxDV:
    http://www.dvdxdv.com/NewFolderLookSite/Products/DVDxDV.overview.htm
    which costs $25.
    For the benefit of others who may read this thread:
    Obviously the foregoing only applies to DVDs you have made yourself, or other home-made DVDs that have been given to you. It will NOT work on copy-protected commercial DVDs, which in any case would be illegal.
    And from the TOU of these forums:
    Keep within the Law
    No material may be submitted that is intended to promote or commit an illegal act.
    Do not submit software or descriptions of processes that break or otherwise ‘work around’ digital rights management software or hardware. This includes conversations about ‘ripping’ DVDs or working around FairPlay software used on the iTunes Store.
    If you are running Lion or later:
    From the MPEG Streamclip homepage
    The installer of the MPEG-2 Playback Component may refuse to install the component in Lion. Apple states the component is unnecessary in Lion onwards, however MPEG Streamclip still needs it. See this:
    http://support.apple.com/kb/HT3381
    To install the component in Lion, please download MPEG Streamclip 1.9.3b7 beta above; inside the disk image you will find the Utility MPEG2 Component Lion: use it to install the MPEG-2 Playback Component in Lion. The original installer's disk image (QuickTimeMPEG2.dmg) is required.
    The current versions of MPEG Streamclip cannot take advantage of the built-in MPEG-2 functionality of Lion. For MPEG-2 files you still need to install the QuickTime MPEG-2 Playback Component, which is not preinstalled in Lion. (The same applies to Mountain Lion and Mavericks even though they have it preinstalled.) You don't have to install QuickTime 7.

  • Help with Runtime class and timeout of Process

    Hi,
    Question regarding using Runtime class, and yes I have looked at the javadocs, but I am still confused and frustrated.
    Here is part of my code.
    Process p;
    Runtime runtime = Runtime.getRuntime();
    p = runtime.exec("rsh localhost ls");
    if you are not familiar with rsh all it does is remote shell into the computer localhost and executes the command ls.
    Now, I dont have rsh running on my computer so it will hang at that line for about 40 sec and eventually time out on its own. Is there anyway I can specify a timeout argument like there is for the ping command? Like if there is no response from localhost after 3 sec, then just kill the process?
    I looked at the Runtime javadoc and Process javadoc and the closest thing I could come to with is something to do with envp (environment parameters), but I dont know what that is.
    Thanks guys.

    You can't timeout the "runtime.exec("rsh localhost ls");" call but if you execute the call in a seperate thread you can "timeout" and continue executing on the original thread (while letting the "runtime" thread to timeout on its own).
    Check the following class that I created for cases like this:
    abstract public class TimeoutHelper implements Runnable
        private Throwable error;
        private boolean running = true;
        private Object retValue;
        protected String name;
        private long waitTime;
        private Thread thread;
         * Creates a new helper. Use {@link #start} to run the code.
         * @param name A name that will be used in the helper thread name
         * @param waitTime The time (in msec) to wait before timeout.
        public TimeoutHelper(String name, long waitTime)
            this.name = name;
            this.waitTime = waitTime;
        public Object start() throws Throwable
            return asyncExecute();
        abstract protected Object execute() throws Throwable;
        private synchronized Object asyncExecute() throws Throwable
            createThread().start();
            if (running)
                try
                    wait(waitTime);
                    if (running)
                        // Timeout!!
                        abortThread();
                        throw new TimeOutException("Timeout for: " + name);
                catch (InterruptedException ie)
                    // Ignore
            if (error != null)
                throw error;
            return retValue;
        private void abortThread()
            if (thread != null)
                thread.interrupt();
        protected Thread createThread()
            thread = new Thread(this, name);
            return thread;
        public void run()
            try
                retValue = execute();
            catch (Throwable th)
                error = th;
            synchronized (this)
                running = false;
                notifyAll();
    }You use the class by extending it and implementing "execute". For example:
            TimeoutHelper helper = new TimeoutHelper("Runner", 5000)
                protected Object execute() throws Throwable
                    Runtime runtime = Runtime.getRuntime();
                    return runtime.exec("rsh localhost ls");
            try
                Process p = (Process)helper.start();
            catch (TimeOutException e)
                // Handle timeout here
            catch (Exception e)
                // Handle other errors here.
            }

Maybe you are looking for

  • ITunes 11 - Apple TV Homesharing Stopped Working

    Hi there I hope someone will have some advice as I've tried just about everything I can think of myself and no joy!  In short, homesharing between my iMac and Apple TV has suddenly stopped working - this is with: Apple TV - 5.1.1 iTunes - 11.0.1 OS X

  • Unable to See Camera Angles in Multi-Camera View

    Hello Adobe Community, I seem to be missing the ability to see my camera angles in Multi-Camera view as you can see in the picture below. I feel it may caused by me trying to get Adobe Encore to work. I have been trying to get Encore by installing an

  • How to Perform Failover When GAP on Standby

    hi , i want to activate my standby in read/write but i can't..i don't have archivelogs and i can't restore standby from incremental backup ALTER DATABASE ACTIVATE STANDBY DATABASE ALTER DATABASE ACTIVATE [PHYSICAL] STANDBY DATABASE (work) Begin: Stan

  • Problem in REM Backflush in Repetetive Mfg

    Hi i got the following error when i try to run the REM BACKFLUSH in repetitive process. (MFBF) " Update control of movement type is incorrect (entry 131 _ _ _ F) Message no. M7226 Diagnosis The system could not find entry 131 _ _ _ F in any of the mo

  • Document ID for attachment in PM Notification

    In which table can I find the document id for the PM Notification attachment? Is there even a document id for that?