View Full Version : Working with string

04-23-2013, 05:28 AM
I'm communication with the server and right now I do this:

PrintWriter out =...

String s = encryptString(request, pass);
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
s = in.readLine();
s = decryptString(s, pass);
s = s.replace("#13#10", "\n");

I have a filling this is not optimal regarding strings. Perhaps too much allocating and stuff. I'm not sure, I don't know about details so much. But if I get big enough string with in.readLine I get out of memory. Perhaps if I change the code I might get out of memory later as I understand that at some point I will get it. Maybe use StringBuilder or something. Any suggestions?