Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

How to send data from selected file in java TCP IP

$
0
0
I am creating a Java TCP socket program in GUI. In which I must send a file from my server part to client. How to to this? I selected the file. In JRadio Button I must select to which client I must send. So when I click the send button It must check which button is clicked and It must send the data to the client. I tried to pass to a method and called the method inside my send action. But I can't pass the data. I am confused. Help me

MY SERVER PART

 public class Server extends javax.swing.JFrame {




    public Server() 
    {
        int server=5555;
        initComponents();
    }

    private void readin(String string, JTextArea jTextArea12) 
    {


         try 
                {
                        String ss=new String(string);


                        System.out.println(ss);

                        content(ss);     // CALLING THIS METHOD WHICH i PASS THE FILE PATH

                        FileReader fr = new FileReader(string);
                        System.out.println();
                        jTextArea1.read(fr, null);
                        fr.close();
                }
                catch (IOException e) 
                    {
                        System.err.println(e);
                    }

    }




    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) 
    {


            if (jRadioButton1.isSelected()) 
            {
                // HERE I MUST CALL THE METHOD IN WHICH I PASSED THE PATH
            }
            else if(jRadioButton2.isSelected())
            {
                heuristic();
            }
            else if(jRadioButton3.isSelected())
            {
                random();
            }
        }






        }
    }

     private void greedy(String s)
     {
         int port=5010;
        if(port==5010)
        {

         // HERE I CONFUSED HOW TO SEND THE CONNECTION IS MADE AND SEND THE DATA TO THE CLIENT?
         String data=s;
         content(data);
        }


     }



My Full code

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>