Realizzazioni
Alcuni siti web realizzati
Isernia, sala del paleolitico
Nelle vicinanze della città di Isernia nell’estate del 1978 sono venuti alla luce i resti di un antichissimo insediamento dell’uomo preistorico risalente a 700.000 anni fa....>>
Mefauno srl
MEFA nasce nel 1975 come azienda a conduzione familiare, e oggi, con un'esperienza più che trentennale, è riconosciuta in tutto il settore come una realtà solida...>>
Meccanica SAR
Nel 1980 nasce a Roma, in via Della Magliana 68F, la S.A.R. Società Artigiana Rettificatori. La grande passione per la meccanica spinge Carlo Montozzi...>>
Dibem srl
La DI.BE.M. rappresenta nel panorama del settore bevande un nome ed una tradizione dal 1971...>>
Home Java Utility Leggere e scrivere in un file properties  2 visitatori online

Leggere e scrivere in un file properties

package utility;

/**
 *
 *
 * @author CUTONE LUCIANO e-mail: \n Questo indirizzo e-mail è protetto dallo spam bot. Abilita Javascript per vederlo. Questo indirizzo e-mail è protetto dallo spam bot. Abilita Javascript per vederlo. Questo indirizzo e-mail è protetto dallo spam bot. Abilita Javascript per vederlo.
 * @version 1.0
 * @since 2008
 * @comment CLASSE PER LEGGERE E SCRIVERE FILE .PROPERTIES
 *
 */

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

 
public class ConfigurationProperties {

    //FILE PROPERTIES
    private static String fileProperties="config.properties";
    
      /**
      *    COTRUTTORE PRIVATO
      */
      private ConfigurationProperties() {
        
      }
      /**
       * <br><b>public static synchronized String getString(String key) </b><br><hr>
       * QUESTO METODO PERMETTE DI RECUPERARE UN VALORE DAL FILE CONFIG.PROPERTIES
       *  
       * <br><b>ReadOnly</b><br>
       * @param pKey DI TIPO STRING
     * @return VALORE DI KEY SE PRESENTE - ALTRIMENTI STRINGA VUOTA
     *
     */
      public static synchronized String getString(String pKey) {
          //VALORE DI RITORNO
          String myReturn="";
          //NUOVA ISTANZA PROPERTIES
          Properties props = new Properties();

          try {
              //CARICO IL FILE DI CONFIGURAZIONE
              props.load(new FileInputStream(fileProperties));
              //LEGGO IL VALORE DI RITORNO
              myReturn = props.getProperty(pKey);
          } catch(IOException e) {
                // utility.showSimpleMessage("ERRORE NELLA LETTURA DEL FILE CONFIG.PRPERTIES NELLA CHIAVE: " + pKey + "\nERRORE: " + e.getMessage());
          }
          //RITORNA myReturn OPPURE UNA STRINGA VUOTA
          return myReturn ;

      }
      
    /**
     * <br><b>public static synchronized void  setProperty(String key, String value)</b><br><hr>
     * QUESTO METODO PERMETTE DI SCRIVERE UN VALORE NEL FILE CONFIG.PROPERTIES
     *  
     * <br><b>WriteOnly</b><br>
     * @param pKey DI TIPO STRING - RAPPRESENTA LA CHIAVE DA INSERIRE
     * @param pValue DI TIPO STRING - RAPPRESENTA IL VALORE CHE SI VUOLE ATTRIBUIRE ALLA CHIAVE
     *
     *
     */
      public static synchronized void  setProperty(String pKey, String pValue)  {
          //CREO UNA NUOVA ISTANZA DI PROPERTIES
          Properties properties = new Properties();
          
          try {
              //CARICO IL FILE
              properties.load(new FileInputStream(fileProperties));
                  //SCRIVO LA CHIAVE
              properties.setProperty(pKey, pValue);
            } catch (IOException e) {
                
                //Utility.showSimpleMessage("ERRORE NELLA LETTURA DEL FILE: " + fileProperties + "\nERRORE: " + e.getMessage());
                System.out.println("ERRORE NELLA LETTURA DEL FILE: " + fileProperties + "\nERRORE: " + e.getMessage());
            }
            

            
            //SALVO IL FILE
            try {
                properties.store(new FileOutputStream("config.properties"), null);
            } catch (IOException e) {
                //Utility.showSimpleMessage("ERRORE NEL SALVATAGGIO DEL FILE " + fileProperties + "\nERRORE: " + e.getMessage());
                 System.out.println("ERRORE NEL SALVATAGGIO DEL FILE " + fileProperties + "\nERRORE: " + e.getMessage());
            }




    }
      

}
 
Notizie flash

Software per l'invio di messaggi di posta elettronica con allegati di grandi dimensioni. Il software sfrutta un repostitory per archiviare i files ed invia, nel messaggio di posta elettronica, solo i links ai files. L'upload è gestito in automatico dal programma ed il download può essere effettuato con qualsiasi browser. Il software è scritto interamente in c#. I files possono essere anche caricati in modo protetto - funzionalità testa su server windows di Aruba.it.