Results 1 to 1 of 1
  1. #1
    k80sg is offline Member
    Join Date
    Mar 2010
    Rep Power

    Default How to receive byte array from Server?

    I am currently coding a client socket and I understand from the example below, the byte array source(myBytes) is within the code, but how can I accept byte array data that are sent from another machine?

    Java Code:
    public class BAM{
    public static void main(String... args){
    		// dummy bytes to manipulate
    		byte myBytes[] = new byte[16];{
    		          mybytes[0] = 4;
                              mybytes[4] = 4;
                              mybytes[8] = 4;
                              mybytes[12] = 4;
    	ByteArrayInputStream bais = new ByteArrayInputStream(myBytes);
     System.out.println("Bytes left in inputstream = " + bais.available()); // displays the available bytes in this stream
    I tried replacing with the line below attempting to get the source from the socket but I get errors:

    ByteArrayInputStream bais = new ByteArrayInputStream(Socket.getInputStream);

    Can someone please advice, any help will be appreciated. Thanks
    Last edited by k80sg; 03-18-2010 at 10:22 AM.

Similar Threads

  1. convert byte array into char array
    By kgkamaraj in forum New To Java
    Replies: 4
    Last Post: 09-13-2011, 11:32 AM
  2. Receive uploaded image / video (byte array) from j2me on jsp.HOW???
    By angelicsign in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 06-29-2010, 06:21 PM
  3. String array to byte array?!
    By Joe2003 in forum Advanced Java
    Replies: 5
    Last Post: 02-28-2009, 06:09 AM
  4. Byte Array
    By sandor in forum New To Java
    Replies: 12
    Last Post: 01-15-2009, 03:31 AM
  5. Replies: 0
    Last Post: 12-02-2008, 10:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts