Sachin H. Gupta

Greenhorn
+ Follow
since Oct 10, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Sachin H. Gupta

Does the Java.net.Socket and java.net.ServerSocket classes use UDP or TCP?
What is mcn and what exactly does MathClient do ?

You can add some code in sendAnswer(number) to wait for an event and then send the code.
The code is reachable but it must be enclosed in the try-catch block as it throws an IOExcpetion

I need to knows how many users are connected to socket



Does that mean "How many users are online ?". Since you have maintained list of connected sockets in Arraylist<Socket> you can easily determine that.

How do I send the message to particular socket connected ?



You need to get an OutputStream on that Socket and send your messages using that.
You don't have to worry about handling user's request, this is done by the application server.
11 years ago

This means the implementation may vary between different platforms



Are there any chances of getting different hashcode values for same object in different platforms.
11 years ago
Following code might help

Output:
Static block of C
Static block of A
Static block of B
Non-static block of A
Constructor of A
Non-static block of B
Constructor of B
11 years ago
You can also use switch-case for comparing Strings (from jdk7), it works similar to equals(). You may also use equalsIgnoreCase() (Java is case sensitive) if you want your output to be correct regardless of upper case or lower case letters.
11 years ago
Yes, it is "THE PROBLEM" and I am sure about it. And the problem is with JMStudio, I am not using my code right now.
11 years ago
I am having problems playing the wav files also. It was working earlier but its not working now.
11 years ago
I installed JMF a few days back on my system, JMStudio was able to play few files at that time. I was using framework for creating a media player. I tried to add plugins for supporting more file formats but things did not worked correctly, so I uninstallled everything realated to JMF. I installed it again and now JMStudio is not playing any file and reports the following error.The PlayerApplet given in jmf-guide gives error "Unable to handle format : <details>" for every file.

Does anyone know what is the problem and how to fix it .
11 years ago
Can I use the following code to create SSLSocket



Or I have to use the SSLSocketFactory ?



Is there any difference in socket if created by different methods. If yes, then which is the preferred way to create a SSLSocket.
Thanks
I copied the program from its current project(Cryptography) to another project and it ran successfully.
I deleted the project Cryptography(including sources), and started a new project named cryptography.
Copied the file again to the project, but it does not executes even now.
The only thing that resolved the problem was
1. delete existing project
2. restart netbeans
3. create new project named cryptography(or any other) and copy files to it.

Please share any information regarding the problem if you know why exactly it is happening.
Thanks
11 years ago
I wrote the code in netbeans and executed it, but I getting an error
"Error: Could not find or load main class CaesarCipher
Java Result: 1"
When I am running it in command prompt, it executes successfully. Please tell me why I am getting this error and the remedy.



/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

import java.io.*;
/**
*
* @author Administrator
*/
class CaesarCipher {

private static BufferedReader buf;



public static void main(String[] args) {
buf = new BufferedReader(new InputStreamReader(System.in));
System.out.println("ex");
CaesarCipher obj = new CaesarCipher();
obj.showMenu();
}

void showMenu(){
System.out.println("1. Encrypt");
System.out.println("2. Decrypt");
System.out.println("3. Exit");
System.out.println("\n Enter your choice");
int ch=0;
try {
ch = Integer.parseInt(buf.readLine());
} catch (Exception e) {
System.out.println("Please Enter a number");
}
switch(ch){
case 1: encrypt();
break;
case 2: decrypt();
break;
case 3: System.exit(0);
default: System.out.println("please enter a valid choice");

}

}

void encrypt(){
System.out.println("Enter the Plain text:");
StringBuilder input=null;
try {
input = new StringBuilder(buf.readLine());

} catch (Exception e) {
}
for (int i = 0; i < input.length(); i++) {
System.out.println((int)input.charAt(i));
}
}

void decrypt(){

}




}

11 years ago