Question: Break down what this code means in sections. import java.io. ; import java.util. ; public class ReadFile{ public static void main(String[] args) throws
Break down what this code means in sections.
import java.io.;
import java.util.;
public class ReadFile{
public static void main(String[]
args) throws
NoSuchElementException {
try {
File myObj = new
File("foo.txt");
Scanner myReader = new
Scanner(myObj);
boolean currentlyInComment
= false;
String line =
myReader.nextLine();
while (line != null)
{ if(line.trim().startsWith("/")){
currentlyInComment =
true;
}
if(!currentlyInComment &&
!line.trim().startsWith("//")){
if(line == ""){
System.out.println("times");
}
System.out.println(line);
}
if(line.trim().endsWith("*/") &&
currentlyInComment) {
currentlyInComment =
false;
}
line = myReader.nextLine();
}
}
catch (Exception ignore){
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Description Break down what this code means in sections import javaio import javautil public class ReadFile public static void mainString args throws NoSuchElementException try File myObj new Filefoot... View full answer
Get step-by-step solutions from verified subject matter experts
