I have many string and i put it in a list.All the strings have this form:
\n Ajax\n
\n JavaScript\n
I just retreived from the server and i put in a list:
takedata.add(result.getBody().getTitle());
How can i cut the \n at both sides?
I have many string and i put it in a list.All the strings have this form:
\n Ajax\n
\n JavaScript\n
I just retreived from the server and i put in a list:
takedata.add(result.getBody().getTitle());
How can i cut the \n at both sides?
List<String> list = new ArrayList<String>();
list.add("\n Ajax\n");
list.add("\n JavaScript\n");
for(int i = 0; i < list.size(); i++)
{
String s = list.get(i).trim();
list.set(i, s);
}
EDIT:
I just retreived from the server with and i put in a list:
takedata.add(result.getBody().getTitle());
How can i cut the \n at both sides?
Simply, use trim():
takedata.add(result.getBody().getTitle().trim());
The title says ArrayList, so
if you have ArrayList<String> list, you can use the method replaceAll(String what, String withWhat)
And the method should be called on list.get(someIndex)
IE> list.get(1).replaceAll("\\n","") Remember you need to insert \ \ in order for java to read that you want to replace the \