ciao ragazzi, ai primi passi in Java volevo sapere se qualcuno fosse in grado di spiegarmi semplicemente come importare valori numerici da un file di testo in una classe java. Grazie in anticipo.
ciao ragazzi, ai primi passi in Java volevo sapere se qualcuno fosse in grado di spiegarmi semplicemente come importare valori numerici da un file di testo in una classe java. Grazie in anticipo.
Walk fast, chew slowly.
"We used students as subjects because rats are expensive and you get too attached to them"
Non č che hai sbagliato forum????
Qui si parla di VB e VB.Net
nooo adesso ho ripostato...che casoiiiiino oggi...scusa IKON, boh cancellami uno dei due post...
Walk fast, chew slowly.
"We used students as subjects because rats are expensive and you get too attached to them"
Properties properties = new Properties();
FileInputStream FIS = new FileInputStream("file.properties");
properties.load(FIS);
FIS.close();
int variable = Integer.parseInt(properties.getProperty("variable" ));
il file deve essere in questo formato
variable=2
ok, grazie mille, ora esiste un modo per far ignorare all´applicazione java parte della linea del documento di testo?
Walk fast, chew slowly.
"We used students as subjects because rats are expensive and you get too attached to them"
la classe Porperties si aspetta un formato come ho scritto
se hai esigenze strane usa altri metodi
ok, allora, date un occhiata a cosa sono andato a combinare. Il tutto funziona piuttosto bene, quello che fa e´prendere degli int da un file di testo e metterli in un array. Ora, mi piacerebbe che il file di testo abbia un formato del tipo
Numero utenti: 35
che si prenda il 35 e ignori tutto il resto, se nel file id testo uso:
35 : numero di utenti funziona correttamente, e´piu´che altro una questione di stile, qualche aiuto?
int[] a1 = new int[10];
for(int i=0; i<a1.length; i++) {a1[i] = 0;}
int i = 0;
String s = null;
StringTokenizer st = null;
BufferedReader in = new BufferedReader(new FileReader("Parameter1.txt"));
while( (s=in.readLine()) != null)
{
st = new StringTokenizer(s);
a1[i] = Integer.parseInt(st.nextToken());
i++;
}
Walk fast, chew slowly.
"We used students as subjects because rats are expensive and you get too attached to them"