Break down what this code means in sections. import java.io. ; import java.util. ; public
Fantastic news! We've Found the answer you've been seeking!
Question:
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){
}
}
}
Related Book For
Posted Date: