import java.util.Scanner;
import java.text.DecimalFormat;
import java.io.*;
public class CommissionsReportFileDemo
{
public static void main(String[] args)throws IOException
{
final double[] rate = {0.01, 0.02, 0.03, 0.05, 0.08}; //Commission Rates
final double[] salesRanges = {0, 10001, 20001, 40001, 50001}; //Sales Ranges
final int SALE_ID = 12;
final int NAME = 12;
String[][]arrayID = new String[SALE_ID][NAME];
int index = 0;
File f = new File("c:\\salesAssociates.txt");
Scanner inputFile = new Scanner(f);
while(inputFile.hasNext()&& index < arrayID.length)
{
arrayID[index][index]= inputFile.nextLine();
index++;
}
inputFile.close();
System.out.println(arrayID);
}
}
I have included the txt file that needs to be read into separate 1 dimensional string arrays. I have managed to complete the rest of my assignment by making a 2 dimensional array within the code that works, but this is where the problem lies. I need to be able to read it from the file into into 2 separate 1 dimensional string arrays.
Attached File(s)
-
SalesAssociates.txt (202bytes)
Number of downloads: 44
This post has been edited by macosxnerd101: 28 March 2011 - 05:56 PM
Reason for edit:: Please use code tags

New Topic/Question
Reply



MultiQuote




|