i have 2 class for example class a and class b. i need the string store at class a pass and use by class b, here is my code for class a and class b.
class a
public void actionPerformed(ActionEvent arg0) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileFilter(new FileNameExtensionFilter("Text Files", "txt"));
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setAcceptAllFileFilterUsed(false);
int returnValue = fileChooser.showOpenDialog(null);
if (returnValue == JFileChooser.APPROVE_OPTION) {
String test;
File selectedFile = fileChooser.getSelectedFile();
test=fileChooser.getSelectedFile().toString();
}
class b
try{
a path = new a();
FileInputStream fis = new FileInputStream(path.test);
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
while((line = br.readLine()) != null)
{
tableModel.addRow(line.split("___"));
}
br.close();
}
catch(IOException e){
JOptionPane.showMessageDialog(null, "Error");
e.printStackTrace();
}
im check using System.out.print for String value test for both class. in class a, i can get the correct value, but in class b, i only get null.