|
ok thankyou for your advices , i have 1 month with me so i will try my best.
|
|
|
|
|
so you have developed a chat server, eh?
smells like homework.
What part of the client do you've got yet?
regards Torsten
I never finish anyth...
|
|
|
|
|
i have modified the information and stated more clearly that i want..please have a look and reply ,
thankyou
|
|
|
|
|
sir/mam
i want to know if i can put the try block directly in a class... as
class a
{
try
{
methods;
}
catch()
{ }
}
|
|
|
|
|
No, a try/catch block has to be inside a method.
What are you trying to achieve exactly ?
|
|
|
|
|
thanks cedric for your reply.
If you don't mind can you please explain why we can't put the try/catch block directly in a class.
why it is required to put it in a method.
|
|
|
|
|
For the same reason why you can't put code directly in a class: it is by design. If you would be able to put code directly in your class (not in a method), what would that mean ?
A try/catch block is meant to surround code that could potentially fail. If you put it directly in a class, it doesn't surround any code.
|
|
|
|
|
Cedric Moonen wrote: If you would be able to put code directly in your class (not in a method), what would that mean ?
That it was static.
class MyClass {
{
System.out.println("This is a static code block");
}
}
Hopefully no-one will actually write a class like that minimalist example, but static code blocks are there for a reason and can be useful under certain circumstances.
|
|
|
|
|
David Skelly wrote: under certain circumstances.
...under very certain circumstances.
I've just cleaned out that stuff out of one of my projects here. A former student used to make (like?) such crucial stuff.
regards Torsten
I never finish anyth...
|
|
|
|
|
I once saw world war III break out over the rights and wrongs of static code blocks between an ex-Smalltalk OO purist and an ex-C++ hacker. No quarter asked or given on either side.
It's like anything: give someone a hammer and they will find a way to hit themselves on the head with it.
|
|
|
|
|
The try{}catch{} mechanism is specifically for catching exceptions thrown within a block of code, i.e inside a method. Putting such a mechanism in a class has no meaning as it includes things like variable definitions, overloaded methods etc.
The best things in life are not things.
|
|
|
|
|
Thanks cedric and richrd.
you solve my problem.
thanks a lot....
|
|
|
|
|
The code you write inside a class are NOT "executable", they're just declarations like variables and methods. The try {} catch {} block is designed to trap errors in executable code. Since only methods contain executable code, try {} catch {} can be placed inside methods only.
|
|
|
|
|
Hello,
My application needs to directly read cookies data from cookies4.dat file that is a cookies firl for Opera browser.
When I load the cookies file of opera it gives me a lot of noise. Here's the <a href="http://img840.imageshack.us/img840/7509/63274022.png">screenshot</a>.
How can I extract(/parse) values for each cookie from that .dat file?
Thanks.
|
|
|
|
|
Just a brief guess - the file ends on *.dat.
For some strange circumstances a *.dat file is a binary file without any specific associated format.
so you've got to give that data some meaning.
You should take a look in the documentation. There you'll find some info on Opera Cookie File Format[^].
regards Torsten
I never finish anyth...
|
|
|
|
|
Thank you. Actually, the problem is that I don't know how to read(/parse/extract values from) that Opera Cookie File Format.
|
|
|
|
|
|
hello every body...
may ,, i want to ask ,how do know the amount of content in the database and display at textfield ?
sorry my language not good
|
|
|
|
|
What do you mean by "the amount of content"; the number of tables, records, columns, bytes etc?
The best things in life are not things.
|
|
|
|
|
kellyyy wrote: how do know the amount of content in the database and display at textfield ?
Steps
1. Learn basic java
2. Learn about GUI programming in java.
3. Learn basic database including SQL. This has nothing to do with steps 1/2.
4. Learn JDBC. This is an API in java. Do NOT attempt this before steps 1 and 3.
5. Put the above together to create a program that does what you want.
|
|
|
|
|
I am writing a java applet that shows FireFox cookies. Is it possible to open the cookies.sqlite file and read that database in Java?
I tried with org.sqlite.JDBC driver but without success. And got exception: file is encrypted or is not a database.
Is it necessary to decrypt the file first or get a permission?
I tried SqlJetDb and it gives exception "org.tmatesoft.sqljet.core.SqlJetException: NOTADB: error code is NOTADB"
Is there anything else do the task of showing FireFox5 cookies?
Thanks.
-- Modified Wednesday, June 29, 2011 8:07 PM
|
|
|
|
|
|
|
Hi,
I'm usually programming in .net but now I have to do a project in java. Nothing wrong with it, but Eclipse demands try/catch blocks on sortof every call which might pose a problem, even if I have error handling in place. How do I get rid of that? I just need a quick check for something, but it even prevents me to compile it.
private void doSomething()
{
Properties properties = readProperties(chooser.getSelectedFile().getCanonicalPath()); <--- compile error
}
private void readProperties(String location)
{
}
While the location of my errorhandling might be debatable, this is for a proof of concept app where I *know* the input is correct.
A good programmer is someone who always looks both ways before crossing a one-way street. (Doug Linder)
|
|
|
|
|
what's wrong? Exceptions need to be catched.
Add the try/catch of the quick fix and go for it. If your code is fine it wont disturb you.
regards Torsten
I never finish anyth...
|
|
|
|