Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: boxes

  1. #1
    Member
    Join Date
    May 2013
    Posts
    165
    Thanks
    58
    Thanked 1 Time in 1 Post

    Default boxes

    I'm writing a client server UDP and it works though remaining bytes are represented as boxes which is something I don't want.
    import java.io.*;
    import java.net.*;
     
     
    public class PacketClientSendDemo{
    	public static void main(String[]args)throws IOException{
    	DatagramSocket socket = new DatagramSocket();
        String tot = "Hello Server";
    	byte[] data = tot.getBytes();
    	InetAddress addr = InetAddress.getLocalHost();
    	DatagramPacket packet = new DatagramPacket(data, data.length, addr,8797);
    	socket.send(packet);
     
    	packet.setData(new byte[1024]);
    	socket.receive(packet);
    	System.out.println(new String(packet.getData()));
     
    	}
    }
    import java.io.*;
    import java.net.*;
     
    public class PacketServerReceiveDemo{
    	public static void main(String[] args)throws IOException{
    	DatagramSocket socket = new DatagramSocket(8797);
    	DatagramPacket packet = new DatagramPacket(new byte[1024],1024);
    	socket.receive(packet);
    	System.out.println(new String(packet.getData()));
    	socket.send(packet);
    	}
    }


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: boxes

    Did you have a question?

  3. #3
    Member
    Join Date
    May 2013
    Posts
    165
    Thanks
    58
    Thanked 1 Time in 1 Post

    Default Re: boxes

    I was wondering how I get output without the boxes representing empty bytes.

  4. #4
    Member
    Join Date
    May 2013
    Posts
    165
    Thanks
    58
    Thanked 1 Time in 1 Post

    Default Re: boxes

    Hello[][][], this is the kind of output I'm getting though the boxes are proper boxes.

Similar Threads

  1. Getting rid of Extra Dialog Boxes
    By ZBixby in forum Java Theory & Questions
    Replies: 7
    Last Post: March 16th, 2013, 12:53 PM
  2. Strange boxes appearing
    By fishnj1333 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 11th, 2012, 05:36 AM
  3. Modifying a complicated object with dialog boxes
    By hunter555 in forum Java Theory & Questions
    Replies: 7
    Last Post: January 27th, 2011, 03:02 PM
  4. Swing Dialog Boxes --- Have no clue why its not working
    By jap2008 in forum What's Wrong With My Code?
    Replies: 9
    Last Post: November 18th, 2010, 04:20 PM
  5. how to write an if statement which evaluates 3 dialogue boxes
    By humdinger in forum Loops & Control Statements
    Replies: 6
    Last Post: January 14th, 2010, 01:28 PM