What is that char �
? and how to remove it from a String? I got it from a BufferedReader
and i got it because i read the contents in a char array and this array has to be assigned to a particular size.So, i got the String like that "aaaaaaa����"
, and I tried trim
and subString
but didn't change anything:
String a = "aaaaaaa����";
//subString
int i = a.lastIndexOf("a");
a = a.substring(0, i+1);
//trim
a = a.trim();
And this is my way to read the input:
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
char[] a = new char[1000];
int line;
String responseLine, server_response = "";
while((line = in.read(a)) != -1) {
responseLine = String.valueOf(a);
server_response = server_response + responseLine;
}
in.close();
return server_response;