public static final String M3UHeader = "#EXTM3U";
public static boolean isValidHeader(String filename)
{
boolean returnValue = true;
BufferedReader br;
try
{
br = new BufferedReader(new FileReader(new File(filename)));
String firstLine = br.readLine();
if(firstLine.startsWith(M3UHeader)) {
System.out.println("isValidHeader:: This file starts correctly.");
}
br.close();
}
catch (Exception e)
{
System.err.println("isValidHeader:: error with file "+
filename + ": " + e.getMessage());
}
return returnValue;
}
public static int getNumberOfTracks(String filename)
{
return 0;
}
}
These are codes that I am working with right now. I need help in getNumberOfTracks method where getTotalSeconds should return the total number of seconds listed in the lines of meta-data in the playlist,
or 0 if the file doesn’t exist, or is invalid.