Results 1 to 5 of 5
- 01-08-2011, 01:33 PM #1
Member
- Join Date
- Jan 2011
- Posts
- 2
- Rep Power
- 0
Extract data from file and store into separate ArrayList
Hi,
I have the following data in my text file.
A:itl208:20001
B:itl209:20003
How do I extract each data and store into separate ArrayList?
For eg.
It should extract A,B and store it in ArrayList1.
It should extract itl208,itl209 and store it in ArrayList2.
I am new to Java and do not have any programming experience.
Can anybody help?
- 01-08-2011, 03:23 PM #2
Senior Member
- Join Date
- Dec 2010
- Location
- Indiana
- Posts
- 202
- Rep Power
- 3
Zero experience ay? I am assuming you know how to make arrays in Java, am I right?
This question could be really loaded if you do not have "any" experience.
What do you know?
java.io.File; ??
java.util.Scanner;?
arrays??
methods and classes?
YouTube - thenewboston's Channel
tutorial 78,79 and 80 are on File reading and writing.
All the tutorials on that page are good.
- 01-08-2011, 04:40 PM #3
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,608
- Rep Power
- 5
See the API for String (Java Platform SE 6), there are several methods you can use to manipulate strings such as this to pull out the info you want (indexOf, split, etc...)
- 01-11-2011, 07:46 AM #4
Hey Komal,
Did you get ahead with this?
Just some pointers, in case if you have not.
1) Use Scanners to read your file. Read it until next line exists.
2) Use String split method to split the contents read by scanner using a regex expression for ":"
3) Use arrays to store the content separated above.
4) Loop through your array and add each element index wise in your ArrayLists.
Read the API documentation links provided in case you need any assistance.
Hope that helps,
GoldestJava Is A Funny Language... Really!.gif)
Click on * and add to member reputation, if you find their advices/solutions effective.
- 01-11-2011, 03:31 PM #5
Similar Threads
-
Need a solution to read and store data from a file
By sheetalnri in forum New To JavaReplies: 10Last Post: 09-30-2010, 06:43 AM -
store data into an array from a file
By chopo1980 in forum New To JavaReplies: 10Last Post: 11-13-2009, 09:48 AM -
Using arrayList to store data from one class to another.
By nickc88 in forum New To JavaReplies: 3Last Post: 03-28-2009, 05:02 AM -
[SOLVED] Extract certain data from file, help
By battousaibounty in forum New To JavaReplies: 4Last Post: 03-07-2009, 09:16 PM -
[SOLVED] How to Extract Data From this text file?
By jazz2k8 in forum New To JavaReplies: 31Last Post: 04-18-2008, 10:45 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks