473,396 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Converting String to Double Problem

9
Hi,

I have retrieved values in a file. Used

Double dval;
String line;
try{

BufferedReader in=new BufferedReader(new FileReader("File1.txt"));
line = in.readLine();
dval=Double.parseDouble(line);
System.out.println(dval);
}
catch(IOException e){}
catch(NumberFormatException e){}

.
.
.
.


Well, I am not getting any errors, Yet dval is not being printed. Please Help me!!
Oct 18 '06 #1
5 5744
looks like your application is not reading the file.Try giving some SOP in the catch block & give a printstack tace there. You might be able to see the error.
Oct 18 '06 #2
For situations such as this you have to make good use of debugging. This means printing various values out to the console to check their validity. You should definitely be using some sort of logging or printing to standard output in all of your error handling from now on. The sooner you can start implementing proper coding practices, the better you will be in the long run.

Good luck!

Steve Hanson
Tasen Software
New Hampshire (NH) Website Design and Software Development
Oct 18 '06 #3
r035198x
13,262 8TB
Hi,

I have retrieved values in a file. Used

Double dval;
String line;
try{

BufferedReader in=new BufferedReader(new FileReader("File1.txt"));
line = in.readLine();
dval=Double.parseDouble(line);
System.out.println(dval);
}
catch(IOException e){}
catch(NumberFormatException e){}

.
.
.
.


Well, I am not getting any errors, Yet dval is not being printed. Please Help me!!
That is not exception handling. That is exception hiding.
Oct 18 '06 #4
Asad
9
That is not exception handling. That is exception hiding.

Well, Could you please tell me whats wrong with my program. I do have the file and its reading from the file too, yet I am unable to convert it to double or any other format using parse, like Integer.parseInt(line); or Double.parseDouble(line);
please help.
Oct 19 '06 #5
r035198x
13,262 8TB
Well, Could you please tell me whats wrong with my program. I do have the file and its reading from the file too, yet I am unable to convert it to double or any other format using parse, like Integer.parseInt(line); or Double.parseDouble(line);
please help.
change
catch(IOException e){}
catch(NumberFormatException e){}
to
Expand|Select|Wrap|Line Numbers
  1. catch(IOException e){
  2.  e.printStackTrace();
  3. }
  4. catch(NumberFormatException e){
  5.  e.printStackTrace();
  6. }
compile and run and see what happens
Oct 20 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: matt melton | last post by:
Hi there, I am trying to write a method that accepts an array of any primitive type and will return the same array without copying memory as an array of bytes. ie. I'd like to be able to do...
4
by: Cyde Weys | last post by:
I'm currently working on converting a simulator program from Visual Basic 6.0 to Visual C++ .NET. I've figured out most of the stuff, but there's still one thing I haven't gotten to and I've never...
4
by: rainmaker1234 | last post by:
Its very simple in VC++. In the followeing code I have declared a String, and a double than I am taking the string and converting it into Double. getch() at the end is only to pause the screen so...
9
by: Coleen | last post by:
Hi All :-) I found the way to get my column sum (Thanks Cor I did it a little different, but the result is what I wanted) I used: dt_stat_report_3b.Columns.Add(New DataColumn("Sum",...
12
by: Frederik Vanderhaeghe | last post by:
Hi, I have a problem converting text to a double. Why doesn't the code work: If Not (txtdocbedrag.Text = "") Then Select Case ddlBedrag.SelectedIndex Case 0 Case 1
7
by: Tor Aadnevik | last post by:
Hi, I have a problem converting values from Single to double. eg. When the Single value 12.19 is converted to double, the result is 12.1899995803833. Anyone know how to avoid this? Regards...
5
by: SMichal | last post by:
Hi, how can I parse string "? 20.000" to double ?
10
by: Ron | last post by:
I want to calculate the surface area of a sphere from an inputed radius with option strict on. I guess I am not converting something correctly. Here is what I am doing: I have a textbox...
3
by: nvx | last post by:
Hi, I'm looking for a simple way to convert a Double to a String exactly the .ToString() does, except these two differences: - the number of decimals is given (rounding is applied if necessary),...
25
by: Blasting Cap | last post by:
I keep getting errors that pop up when I am trying to convert an application from dotnet framework 1.1 to framework 2.0. The old project was saved in sourcesafe from Visual Studio 2003, and I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.