I want write in file .txt and i try this:
save_arq.print("%s;%d:%f;", entry.getValue(), entry.getKey(), result);
I initialize the file this modo:
Scanner file_tf_idf = new Scanner(System.in);
FileWriter arq = new FileWriter("C:\\tf_idf.txt");
PrintWriter save_arq = new PrintWriter(arq);
But i have error in save_arq.print.
My complete code:
public class tfidfWeights {
public Map<String, Integer> tfidf(Map<String, Integer> tf_C) throws IOException{
Scanner file_tf_idf = new Scanner(System.in);
FileWriter arq = new FileWriter("C:\\tf_idf.txt");
PrintWriter save_arq = new PrintWriter(arq);
Map<String, Integer> idf = new HashMap<String, Integer>();
//Set<Integer> doc_id = new HashSet<Integer>(tf_C.keySet());
Set<Entry<String, Integer>> set = tf_C.entrySet();
Iterator it = set.iterator();
Integer N_total = tf_C.size();
while(it.hasNext()){
//iterar o map
Entry<String, Integer> entry = (Entry)it.next();
double result = 0;
result = Math.log10(N_total/entry.getValue());
save_arq.print("%s;%d:%f;", entry.getValue(), entry.getKey(), result);
System.out.print(result);
}
save_arq.close();
}
}
There is no print
method in the PrintWriter
class that accepts those arguments. I'm assuming you wanted to use the printf()
method, which accepts:
printf(String format, Object... args)
So your code would be:
save_arq.printf("%s;%d:%f;", entry.getValue(), entry.getKey(), result);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.