I try to read a file from java, and add it to a JTextArea:
if (e.getSource() == go) {
try {
String strA = field1.getText();
FileReader archr1 = new FileReader(strA);
int valor = archr1.read();
while(valor!=-1) {
System.out.print((char)valor);
area1.setText((char)valor);
valor = archr1.read();
} //fin while
archr1.close();
} catch(IOException r) {
area1.setText("Error: "+r);
} // fin catch
}
To verify that you read the file, I use the print (char) value and if it shows me all the content.
But when I add it to the JTextArea (area1) it returns this error:
"error: incompatible types: char cannot be converted to String"
How could I convert the final result into a String, so that I can show the content in the textarea?
Thank you very much.