I'm new to java. The problem that I'm right now is that I'm sending a file name from the client to the server. When I print that file name in server, it prints fine but it wont match the string that I've hard-coded. Eg: I'm sending 'Lecture.pdf' as a file name from client to server and then I match the received file name with hard coded string 'Lecture.pdf', it wont match and eventually return false. I expect the equal method to return true (as it should).
Here is a code snippet that might demonstrate the problem. 'server' is the object of Socket here, and I'm reading file name using byte array:
InputStream is = null;
byte response [] = new byte [50];
is = server.getInputStream();
is.read(response);
String str_res = new String (response);
System.out.println ("Got reS: " + str_res);
System.out.println ( "Result: "+(response.toString()).equals ("Lecture.pdf"));