Hallo ich habe ein problem mit einem Array das Files auflistet um es zu verstehen hier ist der Code:
Ich möchte gerne "paths" in der darunterlegenden Action aufrufen
Danke im voraus
PS:aus Ausgabe kommt "/Users/Maxi/Desktop/Test/test.txt" (das passt auch)
Java:
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(WIDTH);
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
File f = null;
File[] paths;
try{
// create new file
f = new File("/Users/Maxi/Desktop/Test");
// returns pathnames for files and directory
paths = f.listFiles();
// for each pathname in pathname array
System.out.println(paths[2]);
}catch(Exception e){
// if any error occurs
e.printStackTrace();
}
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
int array = 0;
String str = "";
String[] split = str.split(";");
try
{
while(true){
System.out.println(split[array++]);
}
}
catch (ArrayIndexOutOfBoundsException ex)
{
}
}
Danke im voraus
PS:aus Ausgabe kommt "/Users/Maxi/Desktop/Test/test.txt" (das passt auch)
Zuletzt bearbeitet von einem Moderator: