Posted By:
Robert_Lybarger
Posted On:
Tuesday, July 25, 2006 10:13 PM
You are asking someone to provide a bit more code than most people will probably volunteer time to do. This non-working code fragment might get you pointed in the right direction. You will need to add try/catch blocks around a few things for a compiler to accept it completely, for example:
List list = new ArrayList();
File urlListFile = new File("FileUrlsList.txt");
BufferedReader BR = new BufferedReader(
new FileReader(urlListFile));
String line = null;
while ((line = BR.readLine()) != null) {
// add code to skip blank lines, comment lines, etc.
int lastSlashPos = line.lastIndexOf("/");
// add code to handle a -1 return value
String fileName = line.substring(lastSlashPos);
int lastDotPos = fileName.lastIndexOf(".");
// same comment about -1 return value
String fileNamePrefix = fileName.substring(0,lastDotPos);
list.add(new FileEntry(fileNamePrefix, new URL(line)));
}
BR.close();
return list;