-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaFileFormatter.java
More file actions
64 lines (60 loc) · 1.7 KB
/
JavaFileFormatter.java
File metadata and controls
64 lines (60 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
*
* @author Nathaniel McIntyre (Khila/Khila42)
*/
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
public class JavaFileFormatter
{
private Scanner in;
private PrintWriter output;
public JavaFileFormatter(String fileIn, String fileOut)
throws FileNotFoundException
{
in = new Scanner(new File(fileIn));
output = new PrintWriter(fileOut);
output.println("I'm working!!!!");
}
public static void main(String[] args)
throws FileNotFoundException
{
// TODO code application logic here
Scanner kbd = new Scanner(System.in);
System.out.println("What is the name of the file?");
String fileIn = kbd.next();
kbd.nextLine();
System.out.println("What would you like to name the file for this"
+ " program to write to?");
String fileOut = kbd.next();
JavaFileFormatter f = new JavaFileFormatter(fileIn, fileOut);
//f.formatBrackets();
}
public void formatBrackets()
{
int indents = 0;
for(int i = 0; i <= indents; i++)
{
System.out.print("\t");
}
while(in.hasNext())
{
String word = in.next();
if(word.equals("{"))
{
output.println("\n" + word);
indents++;
}
else if(word.equals("}"))
{
output.println("\n" + word);
indents--;
}
else
{
output.print(word);
}
}
}
}