I'm not sure why you are reinventing the wheel. Java already supports using a hostname or IP address in the net/nio classes. Perhaps your address class is buggy?
You should never process sockets on the same thread you are listening on. You should always spawn another thread to handle the socket you receive from .accept().
This is datastructures and algorithms 101.
A hashtable is guaranteed O(1) lookup.
A list is O(N).
While you might be able to find an item in a list quickly, as N grows, so does your worst case performance (e.g. you are looking for something that is at the end of the list). A hashtables speed...
Properties files can't have more than one key with the same name. End of story.
You can't define a string array in a properties resource bundle. YOu need to create a new implementation of resourcebundle that binds a string array to your given key.
And to followup up petes comment, jsp's and server side programming in general ar ADVANCED topics. If you are this green, stick to basic console apps until your skills and understanding of Java and OO have improved.
doGet and doPost are not requests--they are methods in the HttpServlet class to handle these two HTTP request types.
The basic difference is, form parameters are sent in a GET as part of the request URL. In a POST, they are sent in the request body.
Well, how can the GC remove the WeakReferences when the hashset still has strong references to them? This violates the invariant that the GC must obey that any object that is strongly reachable can never be garbage collected.
What you are looking for can be resolved by using the ReferenceQueue...
If the Object array IS a String array, yes, you can cast it. If was instantiated as an Object array or an array of some type other than String then, no, you cannot cast it.
Is that the whole exception?
Usually when you get a missing resource exception when using a ResourceBundle it is because one of the resources (e.g. properties) that you are trying to access isn't found in the property file. Read up on the RB api--it is pretty clear.
"First of all, about algorithm, pre/post conditions, invariants and such things. Do we need this for writing a program?"
Yes. You need to be thinking of these things when you are programming. You should document your functions/methods with this information as it clearly states what...
Actually, it should be:
Object obj = list.get(i);
String myString = (String)obj;
outFile.write(myString);
However, since every object has a toString method, this is much simpler:
outFile.write(list.get(i).toString());
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.