In the program below i try to search mp3 files and put each file name into array "PlayList" and then print this array. The problems is that i can't put founded files array. Help me please.
package org.kodejava.example.commons.io;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.util.Collection;
import java.util.Iterator;
public class SearchAndSaveMp3
{
public static void main(String[] args)
{
File root = new File("/home/S08/yerzham8/Desktop");
String PlayList[] = new String[5];
int i = 0;
int n = 0;
try
{
String[] extensions = {"mp3"};
boolean recursive = true;
//
// Finds files within a root directory and optionally its
// subdirectories which match an array of extensions. When the
// extensions is null all files will be returned.
//
// This method will returns matched file as java.io.File
//
Collection files = FileUtils.listFiles(root, extensions, recursive);
for (Iterator iterator = files.iterator(); iterator.hasNext();)/>
{
File file = (File) iterator.next();
PlayList[i] = file.getAbsolutePath();
n = i++;
System.out.println("File! = " + file.getAbsolutePath());
}
} catch (Exception e)
{
e.printStackTrace();
}
for (i=0; i<n+1; i++)
System.out.println(PlayList[i]);
}
}
Thank you

New Topic/Question
Reply




MultiQuote




|