How to modify a file .properties

Hi,
I wrote this function in order to modify the values in a generic property file :
    private boolean modifyPropertyValueForAkey(String KeyValue, String propValue) {
        // 1.  acquisire il file properties
        Properties prop = new Properties();
        InputStream inStream = null;
        try {
            inStream =  Computer_STATUS_ForNetworking.class.getResourceAsStream (nameOfThePropertyFile);
            prop.load(inStream); // abbiamo caricato prop (usando inFil)
            // a questo e' servito inStream
            inStream.close(); // chiuso il file per leggere
        } catch (IOException ex) {
           System.out.println("modifyPropertyValueForAkey (IOException 111) " + ex);
        // ======================
        //2.   bisogna avvisare che la modifica non si puo' fare
        if (prop.containsKey(keyValue) == false) {
            return false;
        // ======================
        // 3.  scrivere (= salvare la modifica nel file properties)....
        OutputStream outFil = null;
        try { 
            outFil = new FileOutputStream(nameOfThePropertyFile); // salvato il file
        } catch (FileNotFoundException exep) {
            System.out.println("modifyPropertyValueForAkey (FileNotFoundException 222) " + exep);
        try {
            // key = key_database_path_omTheServer
            prop.setProperty(KeyValue, propValue); // assegnare il valoe
            prop.store(outFil, "---No Comment---");   // salvare la modifica
            // errore la modifica non e' effettuata !!!!!!!!!!!!!!!!!!!!
            outFil.close(); // chiuso il file per scrivere
        } catch (IOException exeption) {
            System.out.println("modifyPropertyValueForAkey (IOException) " + exeption);
        return true;
    }//modifyValuesInApplicationNetworkingConfiguration()I did it following a pattern that I found in the tutorial.
It looks to me to be correct, but it doesn't work..
What it is wrong there ?
I need some help to fix this problem.
thank you
regards
tonyMrsangelo

hi,
thank you for answering me
the function doesn't work because, when the code is executed, the
value of the property (for the key that demand to be modified) doesn't change.
I am not sure about the part of the function that fails
(I know only that no exceptions are raised).
I run this function debugging the program, and
I realized that the .. the bug, in the program, come because the value of
the property that is expected to be changed it is not.
I made several tries to learn more about the fault....
but all I can learned is that, when I open the property file (using the
NetBeans IDE) the value of the property doesn't change..
thank you
regards

Similar Messages

  • How do I set file properties (win XP) ?

    Does anyone know how to set/modify a windows file properties inside Labview ? For exemple : change the author, the comment... etc.
    Thank you !
    J.K.

    Hello,
    It is not possible with advanced file I/O LabVIEW VIs.
    There is a possible workaround by using low level Windows functions in a dll.
    Perhaps the easier would be to set your properties at the top of your file.
    You will find some explanations here :
    http://forums.ni.com/ni/board/message?board.id=170&message.id=85101&requireLogin=False
    regards
    Marc L.
    NIF

  • How to invoke windows file properties menu

    Can we invoke windows file properties menu (just same as right click a file in windows explorer and click properties) in a java program, eg. using shell32.dll?
    Please help!

    Hi Joanne,
    I can't figure out what exactly you're trying do to but just in case... you may simulate a right click using java.awt.Robot class.
    Best regards,
    Lionel Badiou
    CodeFutures -
    Java Code Generation
    http://www.codefutures.com

  • How to modify 'Specified File Name' of a scheduled report

    I run a daily scheduled report every morning and send it out as an emailed attachment. My problem is, I want the file name of the pdf attachment to include the previous day's date. How can I modify the 'Specified File Name' setting in the destination tab to reflect the previous day's date. I do not want to use %SI_STARTTIME% because that only shows the date&time that the report was actually run....I need the previous date. So far I am unsuccessful.
    Thanks

    Hi,
    i think this is only possible via the SDK. I would recommend creating a Support Message with SAP to solve this issue.
    Maybe there is already Samplecode available from the Support.
    Regards
    -Seb.

  • How to change pdf file properties?

    Hi all,
    Preview works great at generating PDFs from Word files, but the metadata fields (e.g., author, title, etc.) don't come over accurately. In Preview, when I click "Get Info," the metadata fields have different values than the original Word document had.
    Anyone know how I can edit the info in the pdf file? Even if I open the properties window through the Finder instead of Preview, I can still only view them, not edit them.
    Thanks

    It isn't actually Preview's fault - at least, I doubt it. I expect you would see the same in any viewer. It could be Word's fault or it could be Apple's underlying PDF creation software. Apple's distiller respects this data when created in other ways, though.
    I didn't suggest the text editing option because it is a little hair-raising editing binary files in that way and I assumed you probably wanted a slightly more user-friendly option. I can see it working if your need is infrequent, though - especially since if anything does go wrong, you can always recreate the PDF from the Word source.
    Good luck with it, anyway.
    - cfr

  • How do read  windows file properties?

    I want to be able to read the size of the file on disk - no the size of the file using file.length() which only gives the size of the file in bytes. also i want to be able to read anyother info that the os is keeping on a file. so, how can i do this? where does windows store property info. fi hope you can help.

    This might work. Copy the following into wordpad and save the folowing as text in the location C:\Windows\.hotjava\ named properties, no extension:
    #AppletViewer
    #Sat Jul 29 14:43:34 2000
    appletviewer.version=1.0

  • How to modify the files in NTFS disk?

    Hello everyone,
    Recently, I find that I can't modify the NTFS or paste a file in it, just because I have not installed the HAL. But as you know hal is removed from pacman repo, so how can I modify the NTFS disk without HAL?
    Waiting for your answer!

    Could you explain how you are mounting the drive? You may have mounted it as read only.
    If you've done it by modifying /etc/fstab, check the options under wiki.archlinux.org/index.php/Fstab.
    If you're using mount (linux.die.net/man/8/mount) make sure you didn't use the -r or -o ro options.

  • How to get remote file properties in Adobe AIR

    Hi Folks,
    I am developing a desktop application in AIR wherein we have a requirement for Live Update. I need a mechanism by which I can check the last modified date time of a file and if a new version is available, I need to download it.
    I am able to download the file from remote server. But the main issue is reading the last modified date time. Is there any way to get this information in AIR.
    Any help/suggestions would be highly appreciated.
    Thanks,
    Hitesh Patel (India)

    This depends on the type of server from which you are downloading the files. For example, if you are downloading the files from an HTTP server, and the server provides "Last-Modified" values in the HTTP response headers, you could use the following ActionScript code to determine those values:
    var urlReq:URLRequest = new URLRequest("http://www.example.com/");
    var urlStream:URLStream = new URLStream();
    urlStream.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, statusListener);
    urlStream.load(urlReq);
    private function statusListener(event:HTTPStatusEvent):void
        for each(var header:URLRequestHeader in event.responseHeaders)
            if(header.name == "Last-Modified")
                trace(header.value);

  • How to get .ai (Adobe illustrator) file properties???

    Hello to all,
                         I am using c# window application framework 3.5 .I am working on the graphics search engine . Now i want to get the .ai (Adobe illustrator)files properties  so please help me how to get .ai files properties?????

    Illustrator file is not just simple one image, that there will be a single image height, width and bit depth available. Illustrator file is made of two components, one is PDF and another is Illustrator private data called PGF. PDF spec is available to everyone while PGF has very limited documentation, but both of them are vector based format, it can contain paths, images, gradient, text etc. They can have multiple pages of varied sizes and each page can have multiple images. So there is no single image height, width or bit depth for the entire file in total.

  • SSIS 2012 Script Task to Get File Properties

    Hello,
    I researched on how to grab a file properties such as file size, file modified date, etc and I came across the following
    link:
    I followed exact steps and when I went to execute the package, I got the following error:
    Below is the code:
    // C# code
    // Fill SSIS variables with file properties
    using System;
    using System.Data;
    using System.IO; // Added to get file properties
    using System.Security.Principal; // Added to get file owner
    using System.Security.AccessControl; // Added to get file owner
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    namespace ST_cb8dd466d98149fcb2e3852ead6b6a09.csproj
    [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    #region VSTA generated code
    enum ScriptResults
    Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
    Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    #endregion
    public void Main()
    // Lock SSIS variables
    Dts.VariableDispenser.LockForRead("User::FilePath");
    Dts.VariableDispenser.LockForWrite("User::FileAttributes");
    Dts.VariableDispenser.LockForWrite("User::FileCreationDate");
    Dts.VariableDispenser.LockForWrite("User::FileExists");
    Dts.VariableDispenser.LockForWrite("User::FileInUse");
    Dts.VariableDispenser.LockForWrite("User::FileIsReadOnly");
    Dts.VariableDispenser.LockForWrite("User::FileLastAccessedDate");
    Dts.VariableDispenser.LockForWrite("User::FileLastModifiedDate");
    Dts.VariableDispenser.LockForWrite("User::FileOwner");
    Dts.VariableDispenser.LockForWrite("User::FileSize");
    // Create a variables 'container' to store variables
    Variables vars = null;
    // Add variables from the VariableDispenser to the variables 'container'
    Dts.VariableDispenser.GetVariables(ref vars);
    // Variable for file information
    FileInfo fileInfo;
    // Fill fileInfo variable with file information
    fileInfo = new FileInfo(vars["User::FilePath"].Value.ToString());
    // Check if file exists
    vars["User::FileExists"].Value = fileInfo.Exists;
    // Get the rest of the file properties if the file exists
    if (fileInfo.Exists)
    // Get file creation date
    vars["User::FileCreationDate"].Value = fileInfo.CreationTime;
    // Get last modified date
    vars["User::FileLastModifiedDate"].Value = fileInfo.LastWriteTime;
    // Get last accessed date
    vars["User::FileLastAccessedDate"].Value = fileInfo.LastAccessTime;
    // Get size of the file in bytes
    vars["User::FileSize"].Value = fileInfo.Length;
    // Get file attributes
    vars["User::FileAttributes"].Value = fileInfo.Attributes.ToString();
    vars["User::FileIsReadOnly"].Value = fileInfo.IsReadOnly;
    // Check if the file isn't locked by an other process
    try
    // Try to open the file. If it succeeds, set variable to false and close stream
    FileStream fs = new FileStream(vars["User::FilePath"].Value.ToString(), FileMode.Open);
    vars["User::FileInUse"].Value = false;
    fs.Close();
    catch (Exception ex)
    // If opening fails, it's probably locked by an other process
    vars["User::FileInUse"].Value = true;
    // Log actual error to SSIS to be sure
    Dts.Events.FireWarning(0, "Get File Properties", ex.Message, string.Empty, 0);
    // Get the Windows domain user name of the file owner
    FileSecurity fileSecurity = fileInfo.GetAccessControl();
    IdentityReference identityReference = fileSecurity.GetOwner(typeof(NTAccount));
    vars["User::FileOwner"].Value = identityReference.Value;
    // Release the locks
    vars.Unlock();
    Dts.TaskResult = (int)ScriptResults.Success;
    Eventually I am looking to just grab the Modified Date from the Windows Explorer folder and insert into table. Any suggestions? Thank you in advance!
    Sanjeev
    Sanjeev Jha

    Hi SSISJoost,
    I am so glad you responded to this thread. You are absolutely right. I copied the entire code including the project name (guid) and that solved the error problem.
    Now, what did you do to get the message box? I added the watch and I could see the values but how do I get these values in a table? If I remember correctly, in your blog, you mentioned something about using derived columns. I am familiar with Derived Columns
    but how do I do that? I appreciate your response.
    Thank you.
    Sanjeev
    Sanjeev Jha
    I used a second script task to show all variable values. It has a
    MessageBox in it and between all
    variables I added a
    newline to make it more readable...
    But with an Execute SQL Task and parameters you can also put these values in a Table... or you can read the file in a Data Flow Task and add those variables (as metadata) to each record with a Derived Column
    Please mark the post as answered if it answers your question | My SSIS Blog:
    http://microsoft-ssis.blogspot.com |
    Twitter

  • Set a file properties to hidden

    how to set a file properties to "hidden" in windows??
    is there anyway of doing that?? help

    how to set a file properties to "hidden" in windows?In WindowsExplorer right click on the icon representing the file and choose "Properties". In the "General" tab and click the "Hidden" check box in the "Attributes" section near the bottom of the dialog box.
    The File class doesn't offer a setHidden() to match isHidden(), so I would guess that this isn't possible in Java without resorting to Runtime.exec() or similar to set the attribute with a command. Windows has an attrib command that does this.
    attrib +h foo.txtEdited by: pbrockway2 on Jan 2, 2008 6:56 PM
    Too slow!

  • How to modify Java options in Oracle 10g Application Server

    I am trying to modify the Java Options to specify the following field:
    -Djavax.xml.transform.TransformerFactory=
    org.apache.xalan.processor.TransformerFactoryImpl
    But I am unable to locate the Server Properties section on the Administration section. I had expanded the Prperties section fully also. I had logged in as oc4jadmin.
    Can anyone help me out in understanding how to modify the Server Properties. I have consulted the Oracle Documentation but still I cant locate the Server Properties section.

    Michel,
    I have logged in using the following URL: http://<machinename>:<port>/em. The URL eventually changes to http://<machinename>:<port>/em/console/ias/oc4j/administration upon successful login.
    I clicked on the Application Server and then clicked on administration link but I dont see Server Properties. I only see the following under Properties section:
    EJB Compiler Settings
    J2EE Websites
    JSP Properties
    Logger Configuration
    Thread Pool Configuration
    Shared Libraries
    I am sure I am missing something here.Can you please help me figure that out please.?

  • How to modify ide.properties file

    Hiiiii..
    With JDeveloper V9.0.5.2
    Whenever I make some changes on jdev/system/ide such as ide.font size.properties and restart the JD, and then open that file(ide.properties), it looks like I didn't make any changes on it and the original data was returned back.
    Please can any one help with this..
    Regard's

    Ensure that you're not modifying this file while JDev is running. It will write the file back out when it shuts down.
    The only other case in which this file gets replaced is if you're migrating from an old release or running a particular release for the first time. The source of this file is jdev/multi/system, so you may be able to modify it there.
    Thanks,
    Brian

  • How can I access the properties of Microsoft files (excel, ppt, and word)

    Hi,
    How can I access the properties of common Microsoft file formats (Excel, Word, and Powerpoint) from a Java program. You can access/modify the properties of each document type using File->Properties in each MS application. The properties are essentially name/value pairs.
    Basically, I need to write a java program that scans a directory and accesses the properties in each of the MS files in the directory.
    thanks,
    -john

    By api. That is only way to establish a contract with the MS programs you want to interface with, unless you write an api yourself! I've used POI and it was an awesome way to use Excel in java. I created an excel spreadsheet from the results of a sql query from a batch program and then it was automatically emailed using javamail to my client. I had a lot of VBA experience with Excel, Word, and Outlook and it didn't take me long to get used to using Jakarta-POI.
    Now I see there is Jakarta-POI-HWPF which works with MS Word documents. Go to: http://jakarta.apache.org/poi/

  • How to modify a specific class in jar file ?

    I've downloaded a jar file for applet, the jar file works fine... but when I extract a specific class file from the jar file and just recompie it from my IDE (Eclipse) without even making any change and then compress again jar class files including the new modified class file instead of the old one (without any modifications to other classes)... then I get
    (NoSuchMethodError ) exception whenever methods of other classes are invoked from within the modified class !!
    ...The manifist file of the jar file reads the following line
    Created-By: 1.4.0_01 (Sun Microsystems Inc.)
    I thought it means that jar class files were built using JDK 1.4.0_01 ...I used JDK 1.5.0_01 in my IDE...
    I thought JRE incompatiblity was the reason of the problem so I downloaded JRE 1.4.0_01 and used it to build this class file... but i got the same exception..
    so what is the main reason of the problem ? ...should I make changes to IDX files accompanying applet jar files ??
    If no, then how can I overcome this problem and be able to change and rebuild a specific class from this jar file ?
    (I cannot rebuild all classes in jar because there are errors I cannot resolve !!)

    Could you please clarify: do you want to run your project or a project from an independent jar?
    In the first case just select Run Project from the project context menu or select a class with main method and click Run File in the class context menu.
    Regarding the second case:
    - I don't think there is such a feature in the IDE (running third party jars is not an IDE function). Could you explain why you need this?

Maybe you are looking for

  • Laptop presario cq61 compaq fails to initialise when i try to open power2go with win 7

    ive never used the power2go burner that came with my laptop ,i bought it just over a year ago from curries and in the end i took it back with in the waranty and they said they fixed it but they never 4 times in a row i would get it home and it never

  • DVDSP3 - First play problem

    Hi I producing a project on DVD SP3. I've done this before but I'm having problems with this particular project. It is a simple project with 1 menu page and a start button. From there you can navigate thru chapters. I have "first play" set to Menu 1

  • S_ALR_87012179 question

    Hello All, In transaction S_ALR_87012179 under the dynamic selection criteria, the credit control area fields do not seem to be turned on. Whenever I input and data and try to search it seems that the fields under that selction are not activated. Doe

  • Best approach to add MVs in OBIEE

    Hi Gurus, Is there a best practice in adding Materialized Views in rpd. Rgds, Amit

  • Convert report to xml document

    hi, how can i create or generate xml document of my report? or how can i generate xml document for whole data of table....? thanks regards shailesh..