Write in file .txt in java
up vote
-2
down vote
favorite
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();
}
}
java file mod-rewrite
add a comment |
up vote
-2
down vote
favorite
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();
}
}
java file mod-rewrite
What is the error? Please post the full stack trace/a Minimal, Complete, and Verifiable example
– GBlodgett
Nov 11 at 3:14
1
There is noprint()
method that accepts those arguments. Did you mean to useprintf()
?
– GBlodgett
Nov 11 at 3:15
1
Also that is not the stacktrace. To see the full stack trace of the errors, re-run Maven with the -e switch.
– GBlodgett
Nov 11 at 3:16
1
Please fix your question so that it is helpful to future visitors -- please post the actual stacktrace. Also are you trying to run non-compilable code? If so, never do that -- get the errors from the compiler and fix those first before trying to run.
– Hovercraft Full Of Eels
Nov 11 at 3:21
add a comment |
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
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();
}
}
java file mod-rewrite
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();
}
}
java file mod-rewrite
java file mod-rewrite
edited Nov 11 at 3:19
Hovercraft Full Of Eels
260k20209316
260k20209316
asked Nov 11 at 3:13
Elaine
118
118
What is the error? Please post the full stack trace/a Minimal, Complete, and Verifiable example
– GBlodgett
Nov 11 at 3:14
1
There is noprint()
method that accepts those arguments. Did you mean to useprintf()
?
– GBlodgett
Nov 11 at 3:15
1
Also that is not the stacktrace. To see the full stack trace of the errors, re-run Maven with the -e switch.
– GBlodgett
Nov 11 at 3:16
1
Please fix your question so that it is helpful to future visitors -- please post the actual stacktrace. Also are you trying to run non-compilable code? If so, never do that -- get the errors from the compiler and fix those first before trying to run.
– Hovercraft Full Of Eels
Nov 11 at 3:21
add a comment |
What is the error? Please post the full stack trace/a Minimal, Complete, and Verifiable example
– GBlodgett
Nov 11 at 3:14
1
There is noprint()
method that accepts those arguments. Did you mean to useprintf()
?
– GBlodgett
Nov 11 at 3:15
1
Also that is not the stacktrace. To see the full stack trace of the errors, re-run Maven with the -e switch.
– GBlodgett
Nov 11 at 3:16
1
Please fix your question so that it is helpful to future visitors -- please post the actual stacktrace. Also are you trying to run non-compilable code? If so, never do that -- get the errors from the compiler and fix those first before trying to run.
– Hovercraft Full Of Eels
Nov 11 at 3:21
What is the error? Please post the full stack trace/a Minimal, Complete, and Verifiable example
– GBlodgett
Nov 11 at 3:14
What is the error? Please post the full stack trace/a Minimal, Complete, and Verifiable example
– GBlodgett
Nov 11 at 3:14
1
1
There is no
print()
method that accepts those arguments. Did you mean to use printf()
?– GBlodgett
Nov 11 at 3:15
There is no
print()
method that accepts those arguments. Did you mean to use printf()
?– GBlodgett
Nov 11 at 3:15
1
1
Also that is not the stacktrace. To see the full stack trace of the errors, re-run Maven with the -e switch.
– GBlodgett
Nov 11 at 3:16
Also that is not the stacktrace. To see the full stack trace of the errors, re-run Maven with the -e switch.
– GBlodgett
Nov 11 at 3:16
1
1
Please fix your question so that it is helpful to future visitors -- please post the actual stacktrace. Also are you trying to run non-compilable code? If so, never do that -- get the errors from the compiler and fix those first before trying to run.
– Hovercraft Full Of Eels
Nov 11 at 3:21
Please fix your question so that it is helpful to future visitors -- please post the actual stacktrace. Also are you trying to run non-compilable code? If so, never do that -- get the errors from the compiler and fix those first before trying to run.
– Hovercraft Full Of Eels
Nov 11 at 3:21
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
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);
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
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);
add a comment |
up vote
2
down vote
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);
add a comment |
up vote
2
down vote
up vote
2
down vote
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);
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);
answered Nov 11 at 3:20
GBlodgett
7,14441329
7,14441329
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245538%2fwrite-in-file-txt-in-java%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What is the error? Please post the full stack trace/a Minimal, Complete, and Verifiable example
– GBlodgett
Nov 11 at 3:14
1
There is no
print()
method that accepts those arguments. Did you mean to useprintf()
?– GBlodgett
Nov 11 at 3:15
1
Also that is not the stacktrace. To see the full stack trace of the errors, re-run Maven with the -e switch.
– GBlodgett
Nov 11 at 3:16
1
Please fix your question so that it is helpful to future visitors -- please post the actual stacktrace. Also are you trying to run non-compilable code? If so, never do that -- get the errors from the compiler and fix those first before trying to run.
– Hovercraft Full Of Eels
Nov 11 at 3:21