Help with java programing oop?
hi basically this code reads from the file after which if the subsequent value inside file is usually an integer them prints it or even the plan throws one message i only desire to find an easy method were it can print this error and then continue processing the information data checking if you find any additional integers
signific java.io.*;
signific java.lang.*;
signific java.util.*;
public class readfile
individual Scanner back button;
public void openFile()
try
x=new Scanner(new File(“README.TXT”));
catch(Exception e)
Method.out.println(“error”);
public void readFile()
try
while(x.hasNextInt())
int we = back button.nextInt();
Method.out.println(i);
catch(NullPointerException e)
Method.out.println(“error”);
catch(NumberFormatException e)
Method.out.println(“error”);
The second an exception is chucked, the performance point finds the test block.Put the try block on the inside of the whilst loop, rather than the when loop inside the attempt block.
You received me…WE found that.http://cool10.info/52483/code-read.
Leave a Reply
You must be logged in to post a comment.