murat gungor

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

Recent posts by murat gungor

Originally posted by Jim Yingst:
Sigh. Read the documentation. "#######" does exactly what it says it will do. So does "#######.0" - I just overlooked your need for a leading zero in the ones position. So use "#######0.0". Test it for other numbers too, to verify it does what you want.


I appreciate your help. I guess my wording is not as exact as you expect. I need nothing but ""(blank or zero length string) if the number is 0(zero)... The pattern ###### is supposed to do that. I did read the doc and that's where I got it from. My problem is, it's not doing what it says it will do. I tested it. It is not doing it. Maybe I should blame the jvm not the language.
23 years ago
Thanks Dave. I have no doubt that this brute force method would work. I was hoping that someone would admit DecimalFormat("#######") is not doing what it promisses to do...
p.s. The problem with this method is, I have to check the pattern too, to see if it is all '#'s, which means I am implementing a kind of extension to format method of DecimalFormat...
23 years ago
That was the first thing I did...
23 years ago

Originally posted by Jim Yingst:
See the documentation for DecimalFormat and try a format string of "#######.0".


This pattern generates ".0" instead blanks...
23 years ago
How can I obtain an empty string for a double that has the value 0.0? I used the code below to achieve this, but I still get "0"...
double numberVal = Double.parseDouble(stringValue);
String formattedValue = new DecimalFormat("#######").format(numberVal));
Thanks in advance.

23 years ago
Thanks for prompt reply!
How can I throw my own exceptions within a SAX DocumentHandler class method? Its methods are defined to throw SAXException only. What if I want to throw other exceptions?
I think Java Cookbook offers a different point of view from reference and some other guide books. It doesn't have direct reference information, or general guidelines. Instead, it has subjects and simple examples to solve particular problems. You may find some examples too simple. It's pretty good for an intermediate, less obvious for a beginner and too general for an advance developer.
I had the opportunity to attend a course instructed by the writer of the book and I think he and his book deserves positive comments. I wish I had it authographed.
23 years ago
I'm having trouble doing serialization of multiple objects to a file. When I use the following code, which opens the file, writes all objects and closes it, it works fine. But when I open the same file and append some other objects, I get "java.io.StreamCorruptedException: Type code out of range, is -84" error.
first version:
ObjectOutputStream oos = new ObjectOutputStream(
new FileOutputStream(fn));
oos.writeObject(new String("string 1"));
oos.writeObject(new String("string 2"));
oos.flush();
oos.close();
second version:
ObjectOutputStream oos = new ObjectOutputStream(
new FileOutputStream(fn,true));
oos.writeObject(new String("string 3"));
oos.flush();
oos.close();
deserialization code is same for both, and only works for first version...what's wrong?


23 years ago