java - How do I send an int array to server (throug socket) as an OutputStream? -


i have array storing few int numbers. want pass array server side server can calculate sum of numbers inside array , send results client. how that?

public static void main(string args[]) {      int[] num = new int[]{0,1,2,3};      if(msg.equalsignorecase("num")){ // msg user input         // send array server            }  } 

to send via network, need serialize somehow. simple case this, can manually (by converting comma separated list, example)

a better approach use well-known data-interchange format, such json. can find many examples online on how serialize json , de-serialize using popular libraries gson , jackson.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -