473,473 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Populate Array of type Double from text file

2 New Member
Hi everyone. This is my first time posting to this forum and I am only about 9 weeks into java programming so I am still learining a lot!

My primary issue is I need to know how to fill an array of type double with values read from a text file.

Update 1.20.12 - So I have made some good progress and now here is what I need help with. In my variable declarations at the beginning of my file I have declared this double array
Expand|Select|Wrap|Line Numbers
  1. double[] interest = {5.35, 5.5, 5.75};
When I get this working properly I know that I will be needing to remove the values from this array so that the text file can populate them, but for testing purposes they are in there.

Next, I have successfully been able to read my text file and to output that to the console window using the following:
Expand|Select|Wrap|Line Numbers
  1.  
  2. try{
  3.     FileInputStream fstream = new FileInputStream("InterestFromFile.txt");
  4.     DataInputStream in = new DataInputStream(fstream);
  5.     BufferedReader br = new BufferedReader(new InputStreamReader(in));
  6.     String strLine;
  7.         while ((strLine = br.readLine()) != null)   {
  8.                System.out.println (strLine);
  9.          }
  10.      in.close();
  11.      }catch (Exception e){//Catch exception if any
  12.      System.err.println("Error: " + e.getMessage());
  13.      }
  14.  
So what I am guessing is that instead of using System.out.println (strLine) to print the contents of the text file to the console window, I will need to change that line to somehow fill the interest[] array that I have already declared earlier, but I don't know how to do that.

Again, thanks ahead of time for your help!
Jan 19 '12 #1
1 1977
bmbuke
2 New Member
Anyone have any ideas? I could really use some help.
Jan 20 '12 #2

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

Similar topics

2
by: Nick | last post by:
Im trying to build an array from elements I have stored in a text file (So I can access them on multiple pages). What is the syntax for this? I thought it might be... storedArray1 =...
5
by: avashisht | last post by:
Hi, I am veeeery new to perl.. i have a script where i am outputting the Environment variable to a HASH. either i want to output hash values into a text file, Or get hash into an array and then...
7
by: pb1uk | last post by:
Hello, I need to read in commands from a text file into an array and i just can't do it. I am trying to use the line filein>>patternarray; and it doesn't work! can anyone help me? Cheers
0
by: centos123 | last post by:
Hi I am trying to build an array out of an input text file as shown below. pattern1 SAF 10 1 10 CLB 20 18 10 11 pattern2 SAF 20 1 10 11
10
by: tnspc | last post by:
I have a function in my program to write an array to a text file, but every way I've tried results in the same result: when I open the file to check what's been written to it, all it displays is the...
3
by: OliveOyl3471 | last post by:
In Visual Basic.NET 2003, how do you populate a two dimensional array from a text file? I know how to check file existence, open the file for read, etc. I just can't get it to read more than one...
11
by: deeptismuley | last post by:
Hello, i want to write an array to a text file using visual basic. the output should look like this for a 5X5 sized array. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0...
3
by: tivicoo | last post by:
I have a 16 bit array called ADData, and i want to save this array to a text file using C#. i tried to use different codes that i located online but when i open the saved data on notepad the data...
7
by: jcnone | last post by:
Does anyone know how to populate form fields on a html web page (client side) with data from an Excel file (CSV) or text file. I am currently having to input data to many text fields manually. I...
2
by: Miguel Valenzue | last post by:
I have written the following code that takes a list called migList, multiplies the strings by 5, then outputs it to a text file called migList.txt #define a list called migList migList = #now...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.