Results 1 to 3 of 3
  1. #1
    _rapt0r_ is offline Member
    Join Date
    Nov 2011
    Posts
    24
    Rep Power
    0

    Default Problem with arrayCopy

    This code connects to an HTTP server and remove all existing ips and put in an array, I wanted to copy this array to another array using arraycopy value in order to use it in another class .. but I always return this [Ljava.lang.String; @ 1786a3c

    someone help me?

    Java Code:
    public class ServidorPresencas extends Thread implements Serializable {
    
        public static String Ips[] = new String[100];
            StringTokenizer IPS;
            Player player;
          
    
        public Server() {
        }
        
        public void run(){     
              try
    		{
    
    		Boolean continuar = true;
    		while(continuar){  	
    			    RecebeTCP crialigacao = new RecebeTCP();
                                Socket ligacao = crialigacao.RecebeTCP(80);
                          
                                DataOutputStream out=new DataOutputStream(ligacao.getOutputStream());
                                InetAddress addr = null;       
                            
                                addr = InetAddress.getLocalHost();
        
                         System.out.println(addr.getHostAddress());      
                 out.writeBytes("GET /heartbeat/heartbeat.svc/show?ip="+addr.getHostAddress()+" HTTP/1.0\n\n");
    
                            out.flush();
                             
                       	BufferedReader in = new BufferedReader (new InputStreamReader(ligacao.getInputStream()));
    			
                            String msg = null;
                            
                            System.out.println("test2\n");
    			int index =0;
    
                            int index2=0;
                            while((msg = in.readLine())!= null)
                            {
           
                              if (index == 10)
                              {
                                IPS = new StringTokenizer(msg,";");		
                               String Ips1[]= new String[100];
                                while (IPS.hasMoreTokens()) {
                                      
                                      String teste=IPS.nextToken();
                                      
                                      Ips1[index2]=teste;
                                      System.out.println("IPS: " + Ips1[index2]);
                                      }
                               System.arraycopy(Ips1, 0, Ips, 0, Ips1.length);          
                                 }
                           
                            index++;
                            }
                    }            
                    try {
                         synchronized(this){
                        
                             wait(30000);
                        
                        }
                    } catch (InterruptedException ex) {
                       Logger.getLogger(ServidorPresencas.class.getName()).log(Level.SEVERE, null, ex);
                    }
    
            }
                            
                    
    		catch (IOException e)
                        {
    			System.out.println("Error server comunication: "+e);
    			System.exit(1);
                        }
    
        }
        public static String[] getOnlineUsers() {
            return Ips;
        }
    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: Problem with arrayCopy

    I always return this [Ljava.lang.String; @ 1786a3c
    That represents what is returned by the Object class's toString method for a String array.
    If you want to see the contents of the array, use the Arrays.toString(<THEARRAYHERE>) method.

  3. #3
    _rapt0r_ is offline Member
    Join Date
    Nov 2011
    Posts
    24
    Rep Power
    0

Similar Threads

  1. Help with System.arrayCopy
    By sehudson in forum New To Java
    Replies: 3
    Last Post: 02-22-2011, 04:28 AM
  2. copy arrays without using arraycopy Method !
    By M7MD in forum Introductions
    Replies: 0
    Last Post: 10-10-2010, 07:59 PM

Posting Permissions

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