i'm really really new to Java. and i came across this question. and i don't know how to do. so if anyone would like to help me in the coding?
Question: i was given a text file in this format.. and was asked to create CD arrays based on the text given. which in this case 4 CD arrays.
[THE TEXT FILE (CD.TXT)] -
4
-
River Classic,Michael bubble,23.50,Crazy love,04:26,Hold on,04:01,Hollywood,03:10,At this moment,03:55
-
Recovery Road,M&Ms,22.00,Love the way you lie,04:23,No love,05:00,Cinderalla Man,04:36
-
Speak forever,Taylor Swifty,20.00,Mine,03:55,Speak now,04:03
-
Best of Me,Eric Charles,18.50,River runs deep,03:33,Rocking chair,04:11,Autumn leaves,05:06,How deep is the ocean,04:02,Travelin' Alone,3:29
-
[END OF TEXT FILE]
the first number ('4') is the array of CD need to be created. then I need to spilt the info according to the CD title, singer, price, tracks [into arrays form] & tracks' length [into array form too]
i did split the info [title, singer & price] but i don't know how to read & store the tracks & the tracks' length into the arrays.
can someone help me?
2 2301
You can use FileInfupStream classes for this. And do you have a code for this?
Regards
Dheeraj Joshi
i tried to do it like this. -
public static void main(String[] argv) {
-
-
BufferedReader br = new BufferedReader(new FileReader ("CD.txt"));
-
-
int count = Integer.parseInt(br.readLine());
-
-
String title = "";
-
String singer = "";
-
Double price = 0.0;
-
String category = "";
-
String discount = "";
-
String tracks [] = new String [30]; // i just make
-
String length [] = new String [30]; // an array of 30s
-
-
for (int i=0; i<count; i++) {
-
String s = br.readLine();
-
StringTokenizer st = new StringTokenizer(s, ",");
-
-
title = st.nextToken();
-
singer = st.nextToken();
-
price = Double.parseDouble(st.nextToken());
-
category = st.nextToken();
-
discount = st.nextToken();
-
-
System.out.println("Title: " + title + "\nSinger: " + singer + "\nprice: " + price +
-
"\ndiscount :" + discount + "\ncategory:" + category);
-
after that, i dont know how to read the tracks & the lengths from the file & store them into the tracks[] and trackLength[] respectively.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Kevin Knorpp |
last post by:
Hello.
I need to be able to extract the data from the attached file (or any file in
the same format) so that I can work with the data in PHP. I'm fairly
comfortable with using PHP with...
|
by: deko |
last post by:
I have a text file ("eighty.txt") that looks like this:
83|84|85|86
I can read the file into an array like this:
$numbers= file("eighty.txt");
But how do I key the array? I'd like to use...
|
by: Colin Steadman |
last post by:
Hope this makes sense!
I'm building an ASP page which allows uses to add items to an invoice
via a form, ie:
Item No Part No Order No Quanity Units Price VAT
------- ...
|
by: ianenis.tiryaki |
last post by:
well i got this assignment which i dont even have a clue what i am
supposed to do. it is about reading me data from the file and load
them into a parallel array here is the question:
Step (1)
...
|
by: lalala |
last post by:
i need to retrieve the data stored in binary format from file into an array to make comparison.Can some1 write me a sample program ?? ermm something like below...
ifstream...
|
by: alkandry911 |
last post by:
hello, Everyone,
am new to C Code and I have a little task am trying to achieve:
I have a text file with a table of 15*30 which has the following format:
ksjdhfbrshyuekjdhsngfurjsleotj...
|
by: almo |
last post by:
hi guys, I have question about writing a function that will store some data from a file in an array, then when that function is call in main, I can use that array in the main() for calculation. Here...
|
by: ryokubaka |
last post by:
In the following code, I have a function that is called in main by the line
Array = Load_File (Filename, &Size);
The function is suppose to do, as the title would suggest, load a file of...
|
by: Arjun Sarankulu |
last post by:
I want to read numbers from XML file
Suppose xml file contain
<number>1</number>
<number>10</number>
<number>20</number>
<number>30</number>
<number>69</number>
The above mention numbers in...
|
by: Jollywg |
last post by:
I have a script that gets all the computer names on the network and saves them as compnames.txt. I would like to read or insert all of the names (delineated by new line) into an array or power shell...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |