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
My Full code
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