For some reason, I'm getting an error. It doesn't seem to be reading
my "input.txt" file. I'm trying to read the "input.txt" file which
consits of random integers and use insertion sort to sort them in
order. Then, i want to have the sorted integers go the file
"output.txt "
static final int MAX_NUM = 100;
public static void main( String[] args ) throws java.io.IOExcep tion
{
int[] num = new int[MAX_NUM];
FileReader fr = new FileReader("inp ut.txt");
BufferedReader br = new BufferedReader( fr );
PrintWriter out = new PrintWriter( new BufferedWriter( new FileWriter(
"output.txt " ) ) );
int count = 0;
while ( count < MAX_NUM )
{
String line = br.readLine();
if( (line == null) || line.equals( "" ) )
break;
try
{
num[count] = Integer.parseIn t( line );
count++;
}
catch( Exception e)
{
System.out.prin tln( "ERROR" );
}
//System.out.prin tln( line );
//line = br.readLine();
}
insertionSort( num );
for( int i = 0; i < count; i++ )
{
out.println( Integer.toStrin g( num ) );
}
out.close();
}
*---------------------------------*
Posted at: http://www.GroupSrv.com
Check: http://www.HotCodecs.com
*---------------------------------*