How do I take to set up for network connect with Socket. I make the JList to press Go to run the post processing (like files). I feel about it and it is not work for me I try to figure out. Thanks.

public final static int port = #### ;(I will put any number)later.
    public final static String hostname = "";(i will put any name) later

 ev1GoButton.addActionListener(new networkListener());

 class networkListener implements ActionListener{
        public void actionPerformed(ActionEvent e){
            Socketnetwork(jListMain.getModel()); (it is not work) 
        }
    }

public void Socketnetwork(String name){
        try{
            Socket networks = new Socket(hostname,port);
            Writer out = new OutputStreamWriter(networks.getOutputStream(),"ASCII");
            BufferedReader in = new BufferedReader(new InputStreamReader(networks.getInputStream(),"ASCII"));
            String s;
            while ((s = in.readLine()) != null){
                if (s.indexOf('\n')>= 0){
                    s = s.replace('\n', ' ');
                    listModel.addElement(s);
                }
            }
        }catch(IOException e){
            JOptionPane.showMessageDialog(JFrame, "Warning, There is not connect!", "Warning dialog", JOptionPane.WARNING_MESSAGE);
        }
    }
This article has been dead for over six months. Start a new discussion instead.