我正在尝试读取一个文件并写入另一个不起作用的文件我从主调用该方法
public boolean copy(String inputPlayList, String outputPlayList, int numberOfMunites)
{
String start1 = "#EXTINF:";
String afterNum = ";";
try
{
声明我将用来传递方法的那些变量
File fInput, fOutput;
String s;
String a;
将这些变量分配给方法
fInput = new File(inputPlayList);
fOutput = new File(outputPlayList);
// Now I am using bufferedRead and BufferedWriter to read and write in a file
BufferedReader br = new BufferedReader(new FileReader(new File(inputPlayList)));
BufferedWriter out = new BufferedWriter(new BufferedWriter(new FileWriter(outputPlayList)));
// creating a while saying while the line is not finish contunue to read
while((s = br.readLine())!= null)
{
if(s.contains(start1)) {
String numberInString = s.substring(start1.length(), s.indexOf(afterNum));
numberOfMunites+= Integer.getInteger(numberInString);
}
// when it is finsh close the file.
out.write(s);
}
out.close();
System.out.println("donne");
}catch ( IOException e)
{
System.err.println("the is an erro that need to be fixed"+e);
}
return false;
}
}