Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    [JAVA] caricare file di properties in hashtable

    ciao a tutti

    dunque in sostanza devo caricare un file di properties (tutto) una volta effettuato il login alla mia applicazione. Vorrei mettere tutti gli elementi in un hashtable che poi andrà in sessione, così da avere sempre tutto a disposizione.

    Il problema è che la classe Properties ha sì un metodo .size() su cui farla ciclare una volta caricato il file, ma poi i dati come li prendo e metto nell'hashtable?
    Properties ha infatti solo metodi get che prendono in input stringhe e non interi, per cui fare ciclare il tutto mi è inutile...

    Posto il codice fatto fin ora

    Properties prop = new Properties();
    HttpSession session=request.getSession();
    ServletContext sc=session.getServletContext();
    String filePath = sc.getRealPath("/")+"WEB-INF/properties/";

    String fileName = "";
    FileInputStream is =null;

    //----------------------------

    fileName="italiano.properties";


    try {
    is = new FileInputStream(new File(filePath+fileName));
    prop.load(is);

    Hashtable ht=new Hashtable();
    for (int i = 0; i<prop.size(); i++){
    //e qui?? :master:
    }

    is.close();
    }catch (IOException ioe) {logger.error(ioe);}





    grazie in anticipo

    Daria
    Realizzazione siti web
    ____________________________
    how terrible thing is knowledge when it brings no profit to the wise...

  2. #2
    ragazzi sono proprio fusa, ho dimenticato che properties implementa hashtable quindi posso mettere direttamente l'oggetto properties in sessione :rollo:

    scusate il disturbo



    hola
    Realizzazione siti web
    ____________________________
    how terrible thing is knowledge when it brings no profit to the wise...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.