title: zeromq - bytearray (from .net server) to string in java
body: <p>I'm working on a project that uses both .net and java, using zeromq to communicate between them.</p>
  
  <p>I can connect to the .net server, however when I try to convert the byte array to a string strange things happen. In the eclipse debugger I can see the string, and its length. When I click on the string its value changes to being only the first letter, and the length changes to 1. In the eclipse console when I try to copy and paste the output I only get the first letter. I also tried running it in NetBeans and get the same issue.</p>
  
  <p>I thought it might be due to Endianness, so have tired both
  BIG_ENDIAN
  LITTLE_ENDIAN</p>
  
  <p>Anyone know how I an get the full string, and not just the first letter?  </p>
  
  <pre><code>import java.io.UnsupportedEncodingException;
  import java.nio.ByteBuffer;
  import java.nio.ByteOrder;
  import org.zeromq.ZMQ;
  
  class local_thr
  {
  private static final String ENDPOINT = "tcp://127.0.0.1:8000";
  static String[]  myargs={ENDPOINT, "1000", "100"};  
    public static void main (String [] args)  {
  
    args = myargs;     
  
    ZMQ.Context ctx = ZMQ.context (1);
    ZMQ.Socket s = ctx.socket (ZMQ.SUB);
  
    s.subscribe("".getBytes());
    s.connect (ENDPOINT);
  
    while(true){
        byte [] data = s.recv (0);
  
  
       ByteBuffer buf = ByteBuffer.wrap(data);
        buf.order(ByteOrder.nativeOrder());
  
        byte[] bytes = new byte[buf.remaining()];
        buf.get(bytes, 0, bytes.length);
  
            String quote;
            quote = new String(bytes);
  
            String myQuote;
            myQuote = new String();
            System.out.println (quote);
      }
    }
   }
  </code></pre>