Come posso convertire un numero intero restituito da read()
in un BufferedReader
al valore del carattere effettivo e quindi aggiungerlo a una stringa? Lo read()
restituisce il numero intero che rappresenta il carattere letto. Come quando faccio questo, non aggiunge il carattere reale nella stringa. Invece, aggiunge la rappresentazione intera stessa alla stringa.Ottenere il carattere restituito da read() in BufferedReader
int c;
String result = "";
while ((c = bufferedReader.read()) != -1) {
//Since c is an integer, how can I get the value read by incoming.read() from here?
response += c; //This appends the integer read from incoming.read() to the String. I wanted the character read, not the integer representation
}
Cosa devo fare per ottenere i dati effettivi letti?
Grazie per la risposta molto chiara! – Fattie
@JoeBlow Grazie per il gentile commento. Per quanto riguarda la modifica, ritengo che la chiusura del lettore sia responsabilità di chiunque abbia creato il lettore. Perché non vediamo la creazione del lettore, chiuderlo non è appropriato qui, e oltre lo scopo della risposta .. – ILMTitan