Question: Write a program that prompts the user for a file name, assuming that the file contains a Java program. Your program should read the file
Write a program that prompts the user for a file name, assuming that the file contains a Java program. Your program should read the file and print its contents properly indented. When you see a left-brace character ( { ) in the file, increase your indentation level by four spaces. When you see a right-brace character ( } ), decrease your indentation level by four spaces. You may assume that the file has only one opening or closing brace per line, that every block statement (such as if or for ) uses braces rather than omitting them, and that every relevant occurrence of a { or } character in the file occurs at the end of a line. Consider using a class constant for the number of spaces to indent (4), so that it can easily be changed later.
Step by Step Solution
3.32 Rating (176 Votes )
There are 3 Steps involved in it
public class PrettyPrint public static final int INDENT 4 public static void mainString ar... View full answer
Get step-by-step solutions from verified subject matter experts
