01: /*
02: * Created on 10/02/2005
03: *
04: * Swing Components - visit http://sf.net/projects/gfd
05: *
06: * Copyright (C) 2004 Igor Regis da Silva Simões
07: *
08: * This program is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU General Public License
10: * as published by the Free Software Foundation; either version 2
11: * of the License, or (at your option) any later version.
12: *
13: * This program is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: * GNU General Public License for more details.
17: *
18: * You should have received a copy of the GNU General Public License
19: * along with this program; if not, write to the Free Software
20: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21: *
22: */
23: package br.com.gfp.windows.config;
24:
25: import java.io.File;
26: import java.io.FileInputStream;
27: import java.io.FileNotFoundException;
28: import java.io.FileOutputStream;
29: import java.io.IOException;
30: import java.util.Properties;
31:
32: /**
33: * Esta classe é responsável por guardar a configuração de localização
34: * no disco local da maquina do usuário.
35: * @author Igor Regis da Silva Simoes
36: * @since 10/02/2005 17:45:21
37: */
38: public class LocaleConf {
39: private Properties localeFile = new Properties();
40:
41: private File arquivo = new File(System.getProperty("user.dir")
42: + File.separator + "lang.conf");
43:
44: /**
45: *
46: * @throws FileNotFoundException
47: */
48: public LocaleConf() throws IOException {
49: if (!arquivo.exists()) {
50: arquivo.createNewFile();
51: } else {
52: FileInputStream fis = new FileInputStream(arquivo);
53: localeFile.load(fis);
54: fis.close();
55: }
56: }
57:
58: /**
59: * Determina um novo país para ser usado pelo GFP
60: * @param country
61: */
62: public void setCountry(String country) {
63: localeFile.setProperty("user.country", country);
64: }
65:
66: /**
67: * Determina um novo idioma para ser usado pelo GFP
68: * @param language
69: */
70: public void setLanguage(String language) {
71: localeFile.setProperty("user.language", language);
72: }
73:
74: public void saveData() throws IOException {
75: FileOutputStream fos = new FileOutputStream(arquivo);
76: localeFile.store(fos, null);
77: fos.flush();
78: fos.close();
79: }
80: }
|