Code example for Properties

Methods: containsKey, getProperty, load

0
         if(!((f.exists())&&(f.canRead()))){
            f.createNewFile();
         } 
             
         //read properties 
         Properties properties = new Properties();
         FileInputStream ResourceFile = new FileInputStream(f);
         properties.load(ResourceFile); 
         return properties;
    } 
     
    /** 
     * Fetches for a given file (the resource's physical file name on the disk) its 
     * original logical name which is stored within an index. 
     * e.g. ce37d69b-64c0-4476-9040-72512f07bb49.TIF to Test1.TIF 
     * @param sFileRandomNumber the corresponding file name or its logical random number if none is available 
     */ 
    private String getIndexFileEntryName(File sFileRandomNumber){
        log.debug("Looking for name of: "+sFileRandomNumber.getAbsolutePath());
        if(sFileRandomNumber!=null){
            try { 
                Properties props = this.getIndex();
                if(props.containsKey(sFileRandomNumber.getName())){
                    //return the corresponding name from the index 
                    return props.getProperty(sFileRandomNumber.getName());
                } 
            } catch (IOException e) {
                // TODO Auto-generated catch block 
                e.printStackTrace();
            }