RSS Forums RSS
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 2494 | Replies: 10 | Thread Tools  Display Modes
Reply
Join Date: Sep 2005
Location: malaysia
Posts: 12
Reputation: boyzz is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
boyzz boyzz is offline Offline
Newbie Poster

Re: how to store the data?

  #11  
Sep 13th, 2005
	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!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 5:41 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC