I have FileHandle class:
public class FileHandle {
public static String a;
public static String b;
public static String c;
public void openFile() throws FileNotFoundException {
File dir = new File("C:/Folder/DB");
if (dir.isDirectory()) {
for (File file : dir.listFiles()) {
Scanner s = new Scanner(file);
//String f = file.getName();
// System.out.println("File name:" + f );
while (s.hasNext()) {
a = s.next();
b = s.next();
c = s.next();
System.out.printf("%s\n %s\n %s\n", a,b,c);
}
}
}
And Constants class:
public class Constants {
FileHandle h = new FileHandle();
public static final String[] LIST_DATA = {FileHandle.a,FileHandle.b,FileHandle.c};
public static final int NEW_ELEMENT_ID = 0;
}
The main question : why in my Constants class i get only last scanned document information. By the way want to mention that FileHandle class scanner is working ok everything is fine. The only real struggle is with sending variables to Constants class there as i mentioned i get only last scanned document information.