1
I’m trying to run this code, but it doesn’t work, from the error in Try{}, in Java it works perfectly.
public void criatxt(){
String texto = "XXX";
try{
PrintWriter arq = new PrintWriter("meudocumento.txt");
System.out.println("Salvou");
arq.print(texto);
arq.close();
}
catch(Exception er){
er.printStackTrace();
System.out.println("Salvou: "+ er.getStackTrace());
}
}
The error in Exception is this: Ljava.lang.Stacktraceelemente;@xxxxxxx
PrintWriter
works normally on Android. If you are giving error intry
, inform in your question which error is giving. If it is a message in logcat, post the text of the message.– Piovezan
of that error: Ljava.lang.Stacktraceelemente;@xxxxxxx
– daniel12345smith
This error is because you printed
er.getStackStrace()
. Exchange forer.getMessage()
orer.getClass().getName()
and say what is being printed. But note that before that you are callinger.printStackTrace()
and the complete exception is being printed on the logcat and that’s what we need here, maybe you’re just not able to find.– Piovezan
I think the file is being saved in a place that can’t, you know how do I create that txt in a specific place like C:?
– daniel12345smith
He is not being saved. He is trying to save but is making an exception, so much so that he printed
er.getStackTrace()
who returnedLjava.lang.StackTraceElemente;@xxxxxxx
. We want to know what the exception is.– Piovezan
If you want to save in a specific place, see this question.
– Piovezan