if (iStream.close()
I am stuck on how to use iStream to print
import java.io.*;
import java.util.*;
public class BucketSort {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in); // This is a scanner for the keyboard
System.out.print("Enter a filename: ");
String fname=sc.nextLine(); // This is the name of the input file
BufferedReader iStream=null; // This represents the input file itself
Scanner fin; // This is a scanner for the input file
try{// The following line opens the file. It must be in a try block
iStream = new BufferedReader(new FileReader(fname));
}
// catch blocks will deal with possible exceptions
catch (FileNotFoundException e)
{System.out.println("Did not find "+fname);}
catch (IOException e) {}
// This instantiates the Scanner for the input file.
fin = new Scanner(iStream);
int num = fin.nextInt(); // This would input the first int in the input file
sc.nextLine(); // clear the input buffer
String[] name = new String[num]; // declare and instantiate an array of num strings
int[] count = new int[num]; // declare and instantiate an array of num ints
for (int i=0; i<num; i++)
name[i] = fin.nextLine(); // input a string for each cell of name
while (sc.hasNext()){ // until the end of the file is reached
int vote = sc.nextInt(); // input another int from the file & call it vote
// process the vote here
}
if (iStream.close() {
// print out the results here.
System.out.print("Enter a fname: ");
System.out.print("Enter a fname: ");
System.out.print("Enter a fname: ");
System.out.print("Enter a fname: ");
System.out.print("Enter a fname: ");
System.out.print("Enter your vote (0-4): ");
}
}
}