|
|
how can i creat a serializable hashtable? please help me!!!
|
|
|
|
|
catch the browser closing event with mozilla firefox in java script
and do a server side database updation
|
|
|
|
|
Was there any need to post this message three times? [Correction] Six times!
Common Sense[^]
Have you heard of Ajax[^]?
My failometer has shot off the end of the scale!
I seem to have misplaced my ban button.. no wait... found it!
|
|
|
|
|
i am developing an application which must send AT coomands to a connected phone to retrieve the contacts. the command i must use is "AT+CPBR". how do i implement this command in my java code? thanks
|
|
|
|
|
ellis eghan wrote: how do i implement this command in my java code?
What do you mean exactly by that ? You simply have to send a string ("AT+CPBR") to your device...
|
|
|
|
|
Dear all
Iam new here,i heard alot about this site,iam trying to make a program that will help deaf people .
so my first step i should be able to detect the mouth weather its OPEN or Close.
any demo or source code or idea,,will be much appreciated.
thanks for the help.
waiting to hear from you
best regards
|
|
|
|
|
Please refrain from double posting, you've posted this in the C# section. Stick to one forum only please.
|
|
|
|
|
catch the browser closing event with mozilla firefox in java script
and do a server side database updation
|
|
|
|
|
catch the browser closing event with mozilla firefox
and do a server side database updation
|
|
|
|
|
I have this method which is the 'find' mthod of a hash table....I don't know why it cannot find the record in a text file
protected int findEntry(Object key) throws InvalidKeyException, IOException {
int avail = 0;
checkKey(key);
int i = hashValue(key);
int j = i;
StudentRecord currentRecord=new StudentRecord();
do {
file.seek(i*StudentRecord.SIZE);
if (currentRecord == null) return -i - 1;
if (currentRecord.flag ==0) {
avail = i;
i = (i + 1) % N;
}
else if (T.isEqualTo(key,currentRecord.stNr))
return i;
else
i = (i + 1) % N;
} while (i != j);
return -avail - 1;
}
|
|
|
|
|
I have this code here:
it uses text files and hash tables to keep some student records:
can somebody help me with the 'FindEntry' Method, i don't really get why it doesn't work....
public class HashTable {
public static class StudentRecord implements Serializable {
public String name,family;
public int stNr,flag;
public static final int SIZE=68;
public StudentRecord() {
name=" ";family=" ";stNr=0;flag=0;
}
public StudentRecord(String name,String family,int stNr,int flag){
this.name=name;
this.family=family;
this.stNr=stNr;
this.flag=flag;
}
public StudentRecord(int key,String value){
stNr=key;
setValue(value);
}
public String getValue(){
return (family+"#"+name+"#");
}
public void setValue(String value){
String t[]=new String[2];
int i=0;
StringTokenizer tokens=new StringTokenizer(value,"#");
while(tokens.hasMoreTokens()){
t[i]=tokens.nextToken();
i++;
}
this.family=t[0];
this.name=t[1];
}
public void write(RandomAccessFile file)throws IOException{
writeName(file,name);
writeName(file,family);
file.writeInt(stNr);
file.writeInt(flag);
}
public void writeName(RandomAccessFile file,String str)throws IOException{
StringBuffer buffer=null;
if(str!=null)
buffer=new StringBuffer(str);
else
buffer=new StringBuffer(15);
buffer.setLength(15);
file.writeChars(buffer.toString());
}
public void read(RandomAccessFile file)throws IOException{
name=readName(file);
family=readName(file);
stNr=file.readInt();
flag=file.readInt();
}
public String readName(RandomAccessFile file)throws IOException{
char name[]=new char[15];
for(int i=0;i<name.length;i++)
name[i]=file.readChar();
return new String(name).replace('\0',' ');
}
}
protected static class DefaultEqualityTester implements EqualityTester {
....
}
protected int n = 0;
protected int N;
File filename1=new File("D:\\b.txt");
RandomAccessFile file=new RandomAccessFile(filename1,"rw");
File filename2=new File("D:\\c.txt");
RandomAccessFile file2=new RandomAccessFile(filename2,"rw");
protected EqualityTester T;
protected int scale, shift;
public HashTable() throws FileNotFoundException, IOException {
N =1023;
T = new DefaultEqualityTester();
java.util.Random rand = new java.util.Random();
scale = rand.nextInt(N-1) + 1;
shift = rand.nextInt(N);
StudentRecord record=new StudentRecord();
for(int i=0;i<N;i++)
record.write(file);
}
public HashTable(int bN, EqualityTester tester) throws FileNotFoundException, IOException {
N = bN;
T = tester;
java.util.Random rand = new java.util.Random();
scale = rand.nextInt(N-1) + 1;
shift = rand.nextInt(N);
StudentRecord record=new StudentRecord();
for(int i=0;i<N;i++)
record.write(file);
}
protected int findEntry(Object key) throws InvalidKeyException, IOException {
int avail = 0;
checkKey(key);
int i = hashValue(key);
int j = i;
StudentRecord currentRecord=new StudentRecord();
do {
file.seek(i*StudentRecord.SIZE);
if (currentRecord == null) return -i - 1;
if (currentRecord.flag ==0) { avail = i; i = (i + 1) % N;
}
else if (T.isEqualTo(key,currentRecord.stNr))
return i;
else
i = (i + 1) % N;
} while (i != j);
return -avail - 1;
}
public Object get (Object key) throws InvalidKeyException, IOException {
StudentRecord currentRecord=new StudentRecord();
int i = findEntry(key);
if (i < 0) return null;
file.seek(i*StudentRecord.SIZE);
return currentRecord.getValue();
}
public void put (int key, String value) throws InvalidKeyException, IOException {
StudentRecord currentRecord = new StudentRecord(key, value);
if (n >= N/2) rehash();
int i = findEntry(key);
if (i < 0) {
file.seek((-i-1)*StudentRecord.SIZE);
currentRecord.write(file);
n++;
}
else {
file.seek(i*StudentRecord.SIZE);
currentRecord.write(file);
}
}
public void remove (Object key) throws InvalidKeyException, IOException {
int i = findEntry(key);
if (i < 0)
else{
StudentRecord currentRecord=new StudentRecord();
while(true){
do{
currentRecord.read(file);
}while(currentRecord.stNr!=key);
currentRecord.flag=0;
}
}
n--;
}.
.
.
.
thanks
|
|
|
|
|
0. Code is unformated
1. It is not urgent for ME.
If you want help, then help us. Format your code so that it is readable. Change the title so tha it is meaningful. Let us know what is happening and what is expected.
The more focused the question, the more liekly you are to get a response.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
ok...so are you able to help now?
|
|
|
|
|
Still urgent is it?
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
i am doing web application.....how to connect the mysql database using javascript...actually i have got in jsp
|
|
|
|
|
Can you specify you requirement ....
I think Java script is for Client side processing.
what if user has disabled JavaScript???
Your database should be consistent, You can call Action/Servlet form JavaScript.
It's not enough to be the best, when you have capability to be great... Jai Shri Ram.
|
|
|
|
|
i am creating an application and i am stuck with my table. i want to be able to navigate through the table by clicking on either a "previous" or "next" button. the table should show display 10 records at a time. any help> thanks
|
|
|
|
|
Hi everyone,
Im having a problem on uploading a text file using jsp. Can anybody give me an idea or sample codes that i can study. Thank you guys in advance.
|
|
|
|
|
hi,jspsmart may help you.But now is not updated.
you can find it on below site:
http://www.whitehouse.net.cn/blog/article/jspsmart_download.html
|
|
|
|
|
How to get the URL of a web page from the address bar in Java that the user is currently working on dynamically i.e.., a program that can get the current working url to the user stored in a string?
Could anybody tell me how to get the URL of the address bar?
Thanks,
Sravanthi
modified on Wednesday, June 17, 2009 3:32 PM
|
|
|
|
|
<title> New Document </TITLE>
</head>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
alert(location);
</script>
</body>
</html>
|
|
|
|
|
I believe this is OK. I need to know if it is possible to draw graphics based on various conditions during run-time, but want some advice before I proceed further.
Thanks.
AF Pilot
|
|
|
|
|
You should be able to get the graphic object jButton.getGraphic() and manipulate it as you need. You should handle it during the refresh of the form as that ensures it is done at the right time.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Thank you, Nagy!
AF Pilot
|
|
|
|