View Single Post
Join Date: Oct 2008
Posts: 37
Reputation: l_03 has a little shameless behaviour in the past 
Solved Threads: 0
l_03 l_03 is offline Offline
Light Poster

How to make an array in text file (help..)

 
0
  #1
Nov 17th, 2008
hello guyzz,,,i am almost finished with my code,,but our teacher require us to access a text file..this is it:

in my text file:

accountList.txt

12345 1234 200000 Jerry Lopez



first column was accountNumber, then the pinNumber, then the balance and the name..

what i did was...

import java.io.*;
public class BankAccount{

public void account(){

File ACCOUNT = new File ("accountList.txt");
FileReader fr = new FileReader(FROZEN);
Reader reader1 = new BufferedReader (fr);
LineNumberReader lnr = new LineNumberReader (reader1);
String line;
for (line = lnr.readLine(); line!=null; line = lnr.readLine()){

String account[] = new String[4];
int count = 0;


int accountNumber[] = Integer.parseInt(account[count][1]);
int pinNumber[] = Integer.parseInt(account[count][2];
int balance[] = Integer.parseInt(account[count][3];
String name = account[count][4];


System.out.println(accountNumber[0][1]);
}
}


i want to sysout the accountNumber,,which is
12345

it has no error when i run it,,but i dont really know what is the problem...

it only print out
0

and i dont know why zero,,,,it seems there is a problem when i declare it...

help guyzzz...i really need your help because we are about to pass it next week,,,,

"that is a shortcut,,i already have the main method.."
Reply With Quote