Please support our Java advertiser: Lunarpages Java Web Hosting
![]() |
•
•
Join Date: Sep 2005
Location: malaysia
Posts: 12
Reputation:
Rep Power: 4
Solved Threads: 0
import java.io.*;
import java.util.*;
public class test
{
public static void main(String[] args)
{
Item[] abc= new Item[10];
String line, subjectName;
int size=0;
try
{
BufferedReader readResults = new BufferedReader(new FileReader("abc.txt"));
subjectName = readResults.readLine();
line = readResults.readLine();
while (line!=null)
{
StringTokenizer tokens = new StringTokenizer(line, ",",false);
String nameToken = tokens.nextToken();
if((tokens.hasMoreTokens()) );
int markaToken = Integer.parseInt(tokens.nextToken());
int markbToken = Integer.parseInt(tokens.nextToken());
abc[size] = new Item(nameToken, markaToken, markbToken);
size++;
line = readResults.readLine();
}
System.out.println(subjectName); /* this 4 lines is to check whether the infomation have been stored*/
System.out.println(abc[0].getname());
System.out.println(abc[1].getmarka());
System.out.println(abc[2].getmarkb());
}
catch(FileNotFoundException e)
{}
catch(IOException e)
{}
}
}
class Item
{
private String name;
private int marka, markb;
public Item(String name, int marka, int markb)
{
this.name=name;
this.marka=marka;
this.markb=markb;
}
public double getmarka()
{
return marka;
}
public double getmarkb()
{
return markb;
}
public String getname()
{
return name;
}
}i finally got it correct... thanks to those look at the thread and help me!
![]() |
Similar Threads
Other Threads in the Java Forum
- how to store and retrieve data from cookies (ASP.NET)
- C++ and data access (C++)
- Store files data into specified memory (RAM) address - help? (Assembly)
- Automatic Data ENtry (Visual Basic 4 / 5 / 6)
- How to load a JPEG image file, store it in array and then save it (Visual Basic 4 / 5 / 6)
- passing parameter to Store Procedure in SqlDataAdapter (VB.NET)
- Using data i read from *.* files (C++)
- Binary data in app.config (C#)
- Internal Data Tables (Visual Basic 4 / 5 / 6)
Other Threads in the Java Forum
- Previous Thread: finding repeated subsequence in string
- Next Thread: Please help me in string operation problem
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)





Linear Mode