Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Populate an arraylist....

Reply
Thread Tools

Populate an arraylist....

 
 
gbattine
Guest
Posts: n/a
 
      06-12-2006
Hi guys,
i'm a new java user and i have a big question for you.
I'm developing a jsf application with eclipse and i have a problem.
I have to import a txt file with this format

string string string string
string double double double
string double double double
string double double double
etc....

The file is composed by a first row that has 4 columns of string type
and other rows of 4 columns with first column string and the others
double.
I have to define 2 object, a first headline object that is an array of
string, for storing the first row, and a second object that is composed
by a string field and by an array of double.

Code:
Headline string[]=new string[4];
public class row{
String geneid=null;
values double[]=null;
}
public void row(String idGene,double[3] x ) {
this.geneid=idPr;
this.values=x;
}
This code is correct?
For storing my file i need an headline array of string and an arraylist
of row objects.
How can populate them with the txt file?
I've loaded the file with
Code:
BufferedReader br = new BufferedReader(new
InputStreamReader(myFile.getInputStream()));
Can you help me with some code?I'm not expert....

 
Reply With Quote
 
 
 
 
Henry
Guest
Posts: n/a
 
      06-12-2006

gbattine wrote:
> Hi guys,
> i'm a new java user and i have a big question for you.
> I'm developing a jsf application with eclipse and i have a problem.
> I have to import a txt file with this format
>
> string string string string
> string double double double
> string double double double
> string double double double
> etc....
>
> The file is composed by a first row that has 4 columns of string type
> and other rows of 4 columns with first column string and the others
> double.
> I have to define 2 object, a first headline object that is an array of
> string, for storing the first row, and a second object that is composed
> by a string field and by an array of double.
>
>
Code:
Headline string[]=new string[4];
>             public class row{
>             	String geneid=null;
>             	values double[]=null;
>             }
>             public void row(String idGene,double[3] x ) {
>                 this.geneid=idPr;
>                 this.values=x;
>               }
This code is correct?
> For storing my file i need an headline array of string and an arraylist
> of row objects.
> How can populate them with the txt file?
> I've loaded the file with
>
Code:
BufferedReader br = new BufferedReader(new
> InputStreamReader(myFile.getInputStream()));
>
> Can you help me with some code?I'm not expert....


I think you've asked this same question or one very close to it several
times in the last several days. I think you've received answers most of
those times. Why aren't you following the suggestions people have given
you? This isn't a terribly difficult problem and I don't expect that
people will keep answering the question for you forever....

--
Henry

 
Reply With Quote
 
 
 
 
Oliver Wong
Guest
Posts: n/a
 
      06-12-2006

"gbattine" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hi guys,
> i'm a new java user and i have a big question for you.
> I'm developing a jsf application with eclipse and i have a problem.
> I have to import a txt file with this format
>
> string string string string
> string double double double
> string double double double
> string double double double
> etc....
>
> The file is composed by a first row that has 4 columns of string type
> and other rows of 4 columns with first column string and the others
> double.
> I have to define 2 object, a first headline object that is an array of
> string, for storing the first row, and a second object that is composed
> by a string field and by an array of double.
>
>
Code:
Headline string[]=new string[4];
>            public class row{
>            String geneid=null;
>            values double[]=null;
>            }
>            public void row(String idGene,double[3] x ) {
>                this.geneid=idPr;
>                this.values=x;
>              }
This code is correct?
> For storing my file i need an headline array of string and an arraylist
> of row objects.
> How can populate them with the txt file?
> I've loaded the file with
>
Code:
BufferedReader br = new BufferedReader(new
> InputStreamReader(myFile.getInputStream()));
>
> Can you help me with some code?I'm not expert....


It's weird. It seems like every other week, you're doing a different
variant on the same problem.

Anyway, if you've solved the previous problem, solving this one should
be easy. It's just like the last one, except instead of an arbitrary number
of columns, you have exactly 3 (or 4, depending on whether you count the
labeling columns).

- Oliver

 
Reply With Quote
 
gbattine
Guest
Posts: n/a
 
      06-12-2006

Excuse me guys
for my repetitive questions, but my problem don't has solution..
My question now is:

I'm using this routine to calculate
public String processMyFile() throws IOException {
BufferedReader br = new BufferedReader(new
InputStreamReader(myFile.getInputStream()));
String line = null;
while ((line = br.readLine()) != null) {
line = line.replace (',', '.');
row++;
StringTokenizer st = new StringTokenizer(line);
numberOfNumericColumns = (st.countTokens()-1);
col=(numberOfNumericColumns+1);

//dichiaro l'oggetto intestazione

to calculate number of rows and columns and it works fine.
I've defined 2 objects

headline string[]=new string[col];

public class riga{
String geneid;
values double[]=null;
}

Arraylist<riga> linee=new Arraylist<linee>();

that represents the first row(headline) and the other rows (riga).
My question is:
how can i modify my code to load txt file into the object headline and
into the arraylist linee?
Excuse me for disturb,please help me with code if it's
possible....thanks

 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      06-13-2006

"gbattine" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ps.com...
>
> Excuse me guys
> for my repetitive questions, but my problem don't has solution..


It'd probably be easier to solve your problem if it didn't keep changing
every day. How are you able to do this? Is your client changing his/her
mind? Or are did you manager to convince the teacher that the assignment is
too difficult, or what?

If you keep changing your problem, I get very discouraged about helping
you, because if I invest, say 2 hours, to explain to you how to sovle your
problem, the next day you'll just post a completely new problem and I
wouldn't have ended up helping you anyway. That's 2 hours wasted that I
could have spent helping someone else.

> My question now is:
>
> I'm using this routine to calculate
> public String processMyFile() throws IOException {
> BufferedReader br = new BufferedReader(new
> InputStreamReader(myFile.getInputStream()));
> String line = null;
> while ((line = br.readLine()) != null) {
> line = line.replace (',', '.');
> row++;
> StringTokenizer st = new StringTokenizer(line);
> numberOfNumericColumns = (st.countTokens()-1);
> col=(numberOfNumericColumns+1);
>
> //dichiaro l'oggetto intestazione
>
> to calculate number of rows and columns and it works fine.
> I've defined 2 objects
>
> headline string[]=new string[col];
>
> public class riga{
> String geneid;
> values double[]=null;
> }
>
> Arraylist<riga> linee=new Arraylist<linee>();
>
> that represents the first row(headline) and the other rows (riga).
> My question is:
> how can i modify my code to load txt file into the object headline and
> into the arraylist linee?
> Excuse me for disturb,please help me with code if it's
> possible....thanks


Your braces aren't balanced, and there's no return statement, although
the method is declared as returning a string. It'll be easier if you post an
SSCCE: http://mindprod.com/jgloss/sscce.html

- Oliver

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
EAP type list doesn't populate with anything =?Utf-8?B?Z3MzMDBib2k=?= Wireless Networking 0 07-11-2005 08:51 PM
Best way to recursively populate a tree based on SQL Server 2000 backend Mark ASP .Net 9 05-28-2005 08:54 PM
populate one list box with selected values from another list box steven.cooper@infocision.com ASP .Net 1 03-12-2005 11:29 PM
Populate a popup window with clickable records from an Access DB and upon clicking, populate a selectbox on the original webpage with the clicked record Enjoy Life ASP General 2 02-23-2005 10:48 PM
How to populate a checkbox from a database Lamine Darbouche ASP .Net 1 02-16-2004 02:02 PM



Advertisments