title: Server/client in java and c/objective - Encoding issues
body: <p>I'm trying to write simple code for server/client.</p>
  
  <h3>The server (in java) wait for string from client:</h3>
  
  <pre><code>ServerSocket ss = new ServerSocket(4001);
  Socket s = ss.accept() ;
  
  DataInputStream dataStreamIn = new DataInputStream(s.getInputStream()) ;
  
  byte buffer[] = new byte[100];
  
  dataStreamIn.read(buffer);
  
  
  if((new String(buffer)).equals("1"))
      System.out.print("yes");//never printed
  </code></pre>
  
  <h3>the client (objective-c) send string to server:</h3>
  
  <pre><code>uint8_t buffer[1000] ={0};
  sprintf((char*)buffer,"%s", "1");
  
  NSInteger wrote = [self.networkStreamOut 
                     write:buffer 
                     maxLength:(uint8_t)strlen((char *)buffer)];
  </code></pre>
  
  <p>The problem is the buffer on server is indeed "1" BUT when I'm trying to compare with .equals() it return false! </p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>When I'm tring to add to server this line:</p>
  
  <pre><code>System.out.println(Integer.valueOf(new String(buffer))) ;
  </code></pre>
  
  <p>I'm getting this error:</p>
  
  <pre><code>Exception in thread "main" java.lang.NumberFormatException: For input string: "1
  </code></pre>