also habe folgenden code:
aber wie benutze ich die Variabeln: radius1, radius2 und radius 3 in einer anderen Klasse?
Java:
package readfiles;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.StringTokenizer;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author tom
*/
public class ReadFiles {
public ReadFiles() {
readFile();
}
public void readFile() {
JFileChooser chooser = new JFileChooser();
int r = chooser.showOpenDialog(new JFrame());
if (r == JFileChooser.APPROVE_OPTION) {
String path = chooser.getSelectedFile().getPath();
BufferedReader inputStream = null;
try {
inputStream = new BufferedReader(new FileReader(path));
String l;
while ((l = inputStream.readLine()) != null) {
String alleRadien =(l);
StringTokenizer werte = new StringTokenizer(alleRadien, "|");
int radius1 = Integer.valueOf(werte.nextToken());
int radius2 = Integer.valueOf(werte.nextToken());
int radius3 = Integer.valueOf(werte.nextToken());
System.out.println(radius1);
System.out.println(radius2);
System.out.println(radius3);
}
} catch (IOException ex) {
System.out.println("ERROR: File not found or access not possible: " + path);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException ex) {
System.out.println("ERROR: File close failed for: " + path);
}
}
}
}
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
ReadFiles rf = new ReadFiles();
rf.readFile();
}
});
}
}
aber wie benutze ich die Variabeln: radius1, radius2 und radius 3 in einer anderen Klasse?