Click here to Skip to main content
15,910,981 members
Home / Discussions / Java
   

Java

 
QuestionJScrollPane is not showing the frame properly Pin
chdboy14-Oct-13 19:36
chdboy14-Oct-13 19:36 
AnswerRe: JScrollPane is not showing the frame properly Pin
Shubhashish_Mandal16-Oct-13 20:51
professionalShubhashish_Mandal16-Oct-13 20:51 
Questionjava file Pin
hemanthpoluru13-Oct-13 15:19
hemanthpoluru13-Oct-13 15:19 
AnswerRe: java file Pin
Richard MacCutchan13-Oct-13 20:46
mveRichard MacCutchan13-Oct-13 20:46 
AnswerRe: java file Pin
Logical9416-Oct-13 19:09
professionalLogical9416-Oct-13 19:09 
Questionabout java socket Pin
rualchina12-Oct-13 4:48
rualchina12-Oct-13 4:48 
AnswerRe: about java socket Pin
jschell12-Oct-13 10:34
jschell12-Oct-13 10:34 
GeneralRe: about java socket Pin
rualchina12-Oct-13 17:19
rualchina12-Oct-13 17:19 
it is implemented on the basis of the code
package socket_tcp;

import java.io.*;
import java.net.*;

public class jTcpCliOnly {
public static void main(String[] args) throws IOException {
Socket echoSocket = null;
PrintWriter out = null;
BufferedReader in = null;
String hostName = new String("hp-HP"); //Your: [XXXXXX] to get

try {
echoSocket = new Socket(hostName, 7000);
out = new PrintWriter(echoSocket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(echoSocket.getInputStream()));
} catch (UnknownHostException e) {
System.err.println("Don't know about host: " + hostName);
System.exit(1);
} catch (IOException e) {
System.err.println("Couldn't get I/O for " + "the connection to: " + hostName);
System.exit(1);
}

BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
String userInput;
while ((userInput = stdIn.readLine()) != null) {
out.println(userInput); //write what user input to TCP server
System.out.println("echo: " + in.readLine());
}
out.close();
in.close();
stdIn.close();
echoSocket.close();
}

}
___________________________________________________________-
package socket_tcp;

import java.io.*;
import java.net.*;

public class jTcpSerOnly {
public static void main(String[] args) throws IOException {
boolean flag = true;
ServerSocket serverSocket = null;
Socket clientSocket = null;
String inputLine;
BufferedReader is = null;
PrintWriter os = null;

try {
serverSocket = new ServerSocket(7000);
System.out.println("Server listen on: " + serverSocket.getLocalPort());

while (flag) {
clientSocket = serverSocket.accept();
is = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
os = new PrintWriter(clientSocket.getOutputStream(), true);
while ((inputLine = is.readLine()) != null) {
if (inputLine.equals("Stop!")) {
flag = false;
break;
}
System.out.println("Server: " + inputLine);
os.println(inputLine);
os.flush();
}
os.close();
is.close();
clientSocket.close();
}
} catch (IOException e) {
System.err.println("Exception: " + e);
}
}

}
GeneralRe: about java socket Pin
rualchina12-Oct-13 17:24
rualchina12-Oct-13 17:24 
GeneralRe: about java socket Pin
Richard MacCutchan12-Oct-13 23:58
mveRichard MacCutchan12-Oct-13 23:58 
GeneralRe: about java socket Pin
rualchina13-Oct-13 4:02
rualchina13-Oct-13 4:02 
GeneralRe: about java socket Pin
Richard MacCutchan13-Oct-13 4:53
mveRichard MacCutchan13-Oct-13 4:53 
GeneralRe: about java socket Pin
jschell14-Oct-13 8:00
jschell14-Oct-13 8:00 
QuestionImage transfer using TCP/IP Pin
Claraviolet10-Oct-13 5:22
Claraviolet10-Oct-13 5:22 
AnswerRe: Image transfer using TCP/IP Pin
Richard MacCutchan10-Oct-13 6:18
mveRichard MacCutchan10-Oct-13 6:18 
GeneralRe: Image transfer using TCP/IP Pin
Albert Holguin15-Oct-13 14:48
professionalAlbert Holguin15-Oct-13 14:48 
GeneralRe: Image transfer using TCP/IP Pin
Richard MacCutchan15-Oct-13 21:18
mveRichard MacCutchan15-Oct-13 21:18 
AnswerRe: Image transfer using TCP/IP Pin
Logical9416-Oct-13 19:04
professionalLogical9416-Oct-13 19:04 
QuestionAdding more than one JPanel to my JFrame(North,South) Pin
chdboy7-Oct-13 18:02
chdboy7-Oct-13 18:02 
SuggestionRe: Adding more than one JPanel to my JFrame(North,South) Pin
Richard MacCutchan7-Oct-13 21:31
mveRichard MacCutchan7-Oct-13 21:31 
GeneralRe: Adding more than one JPanel to my JFrame(North,South) Pin
chdboy9-Oct-13 1:13
chdboy9-Oct-13 1:13 
GeneralRe: Adding more than one JPanel to my JFrame(North,South) Pin
Shubhashish_Mandal9-Oct-13 3:15
professionalShubhashish_Mandal9-Oct-13 3:15 
GeneralRe: Adding more than one JPanel to my JFrame(North,South) Pin
chdboy9-Oct-13 19:04
chdboy9-Oct-13 19:04 
GeneralRe: Adding more than one JPanel to my JFrame(North,South) Pin
Richard MacCutchan9-Oct-13 4:24
mveRichard MacCutchan9-Oct-13 4:24 
GeneralRe: Adding more than one JPanel to my JFrame(North,South) Pin
chdboy9-Oct-13 19:03
chdboy9-Oct-13 19:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.