sangeetha balasubramaniam

Greenhorn
+ Follow
since May 16, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sangeetha balasubramaniam

Is there anyway to append the content of the file.

Right now I am reading the already existing content, then making the necessary append to the content. Finally writing the whole content to file.

I am using BufferedReader for reading and OutputStream for writing.
17 years ago
How to to check, whether the input is a number.

eg: telephone number
17 years ago
import java.rmi.*;
import java.rmi.server.*;
import java.util.*;
public class SellerRegistration{ //Client

/**
* Method main
*
*
* @param args
*
*/
public static void main(String[] args) {
try{
if(System.getSecurityManager() == null){

System.setSecurityManager(new RMISecurityManager());
}
RemoteInterface sellerInterface = (RemoteInterface)Naming.lookup("Seller");

//Creation of SellerObject from user input(1.Name, 2.Email, 3.TelephoneNumber)
SellerObject sellerObj = new SellerObject();
System.out.println(" Please enter the inputs 1)Name 2)Email 3)Telephone Number in this given order");

//Validate the user input
if(args.length == 3){

sellerObj.setName(args[0]);
sellerObj.setEmail(args[1]);
sellerObj.setTelephoneNumber(Integer.parseInt(args[2]));

}
else{
System.out.println("Invalid Number of user Input");
}

String sellerId = sellerInterface.sellerRegistration(sellerObj);

System.out.println("before writing to Seller Log file");

//Enter the success message for the Registration in Seller's Log File
String filePath= "C:\\j2sdk1.4.2_12\\bin\\DistributedSystems\\SellerLogfile.txt";
String action = "Register";

//Check whether the sellerId is valid to know the correct status
String status = "";
if(sellerId != null && !sellerId.equals("")){
status = "Success";
}else{
status = "Fail";
}
String[] contents = new String[3];
contents[0] = args[0];
contents[1] = args[1];
contents[2] = args[2];
new Service().writeToLog(filePath, action, status, contents);

System.out.println("after writing to Seller Log file");

}catch(Exception e){
System.out.println(e);
}

}
}

=================================

import java.rmi.*;

public class Broker { //Server

/**
* Method main
*
*
* @param args
*
*/
public static void main(String[] args) {
System.setSecurityManager(new RMISecurityManager());
System.out.println("Main OK");
try{
RemoteInterface sellerInterface = new RemoteServant();
System.out.println("After creating Servant");
Naming.rebind("Seller", sellerInterface);
System.out.println("Broker Ready");
}catch(Exception e){
System.out.println("Broker server main");
}

}
}
17 years ago
I was able to start the rmiregistry and server, but when I start my client, I am left with this error "java.rmi.NotBoundException".
I had checked for the binding name, everything looks correct for me. Pls someone help me
17 years ago
Hi,
I want to create a JSP with dropdown containing names of the sub folders which in present inside the folder.

Say a Folder A, has A1, A2, A3 and want to display A1, A2 and A3 in the dropdown, how to do this.pls help


Thanks in Advance
Sangeetha.
18 years ago
JSP
Hi Jimmy,
i am using windows xp / jdk 1.3.1_15
Hi Jimmy,
i am using windows xp / jdk 1.3.1_15
Hi Jimmy,
Can you explain the element 3 and element 4. i have a doubt as why it agian inserts the char a in element 3 and char b in element 4.
Hi,

I got the result as ababcdcd what you expected.
I am really confused as why everyone is getting a different answer, can some help us please



Thanks in Advance,
Sangeetha
Hi,

public class MyClass
{
//first method
public static void main(String args[])
{
System.out.println("In first main()");
}

//Second method
public static void main(char args[])
{
System.out.println('a');
}
}

I have a doubt as how to invoke this Second method, firstly whether it is possible, if so how..explain please.

Thanks in Advance,
Sangeetha
Yes. charValue() is available in Character class
Hey Thomas,

both eg1 and eg2 definetely complies for sure.Becasue i compiled and got those answers.

In eg2 , when you change the line "question.method(null);" , definetely for sure it will give the compiler error as ambiguous.So i doubt you did that.Can you post the code which you tired..Please..
I found this question in abhilash.

eg 1:

public class AQuestion {
public void method(Object o) {
System.out.println("Object Verion");
}
public void method(String s) {
System.out.println("String Version");
}
public static void main(String args[]) {
AQuestion question = new AQuestion();
question.method(null);
}
}

Answer: String Version

eg 2:

public class AQuestion {
public void method(StringBuffer sb) {
System.out.println("Object Verion");
}
public void method(String s) {
System.out.println("String Version");
}
public static void main(String args[]) {
AQuestion question = new AQuestion();
question.method("");
}
}

Answer: String Version

Can anyone explain me, how this selects the particular method..Please
Hi,

Can a hashcode overridden from Object, can return other than int.

Because i can an object which has teh value that sis greater then the int can hold.No way of reducing the value of my object, because i have to check against the same object.I even tried dividing the value by some int to make it smaller value so taht it can fit in int, this case recults me in same hashcode for different objects.

String pid = "P1/000032";
String cid = "20"
public int hashCode(){
StringBuffer tempProj = new StringBuffer(50);
tempProj.append(pid.replaceAll("/","").replaceAll("T","3").replaceAll("P","2").replaceAll("C","1").replaceAll("D","4"));

long lValue = Long.parseLong(tempProj.toString())/(Integer.parseInt(cid)*99);
return (int)lValue;
}

Above code returns 10606 for pid = "P1/000032" and also "P1/000034".Help please.
18 years ago
No,
i want a valid reason, as why the above code not following the operator precedence..Please someone help me...



Thanks,
Sangeetha.