我定义size_list
作为一个ArrayList Long
。 我做import java.io.*;
已经。 不知怎的,下面还是给了我一个错误。 我在做其他的职位,我碰到同样的事情。 有没有人出了什么问题?
ArrayList<Long> size_list = some_method();
try{
FileWriter fileWriter = new FileWriter("results.txt");
BufferedWriter out = new BufferedWriter(fileWriter);
for(int i = 0; i < size_list.size(); i++ ){
out.write(size_list.get(i));
out.newline();
}
out.close();
} catch(IOException ex){
System.out.println("Error writing to file " );
}
该错误消息我:
no suitable method found for write(Long)
out.write(size_list.get(i));
^
method Writer.write(int) is not applicable
(argument mismatch; Long cannot be converted to int)
method Writer.write(char[]) is not applicable
(argument mismatch; Long cannot be converted to char[])
method Writer.write(String) is not applicable
(argument mismatch; Long cannot be converted to String)
method BufferedWriter.write(int) is not applicable
(argument mismatch; Long cannot be converted to int)
SCCsAlgo.java:287: error: cannot find symbol
out.newline();
^
symbol: method newline()
location: variable out of type BufferedWriter