Source code
package max;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class Max {
public static void main(String[] args) throws IOException
{
try {
BufferedReader br = new BufferedReader(new FileReader("numbers.txt"));
String str;
while((str=br.readLine())!=null)
{
String data[] = str.split(",");
int size=data.length;
int max = Integer.parseInt(data[0]);
for(int i=0;i<size;i++)
{
int a = Integer.parseInt(data[i]);
if(a>max)
{
max=a;
}
}
System.out.println("Max: "+max);
}
} catch (FileNotFoundException ex)
{
System.out.println("Problem Detected !!!!");
}
}
}
Output
Input File:

Max: 12
Max: 20
Max: 7
Add your comment