- import java.io.*;
- import java.lang.*;
- import java.util.Scanner;
- public class FormatFile {
- File newfile;
- public FormatFile(File format){
- newfile = format;
- }
- public void check() throws FileNotFoundException{
- Scanner input = new Scanner(newfile);
- while (input.hasNext()){
- String returnstring = input.next();
- int holder = returnstring.length();
- returnstring.replace("assert", "<FONT COLOR=RED>assert</FONT>");
- returnstring.replace("break", "<FONT COLOR=RED>break</FONT>");
- returnstring.replace("case", "<FONT COLOR=RED>case</FONT>");
- returnstring.replace("public", "<FONT COLOR=RED>public</FONT>");
- returnstring.replace("long", "<FONT COLOR=RED>long</FONT>");
- returnstring.replace("double", "<FONT COLOR=RED>double</FONT>");
- returnstring.replace("extends", "<FONT COLOR=RED>extends</FONT>");
- returnstring.replace("abstract", "<FONT COLOR=RED>abstract</FONT>");
- returnstring.replace("boolean", "<FONT COLOR=RED>boolean</FONT>");
- returnstring.replace("byte", "<FONT COLOR=RED>byte</FONT>");
- returnstring.replace("char", "<FONT COLOR=RED>char</FONT>");
- returnstring.replace("class", "<FONT COLOR=RED>class</FONT>");
- returnstring.replace("for", "<FONT COLOR=RED>for</FONT>");
- returnstring.replace("final", "<FONT COLOR=RED>final</FONT>");
- returnstring.replace("finally", "<FONT COLOR=RED>finally</FONT>");
- returnstring.replace("float", "<FONT COLOR=RED>float</FONT>");
- returnstring.replace("catch", "<FONT COLOR=RED>catch</FONT>");
- returnstring.replace("char", "<FONT COLOR=RED>char</FONT>");
- returnstring.replace("const", "<FONT COLOR=RED>const</FONT>");
- returnstring.replace("continue", "<FONT COLOR=RED>continue</FONT>");
- returnstring.replace("default", "<FONT COLOR=RED>default</FONT>");
- returnstring.replace("else", "<FONT COLOR=RED>else</FONT>");
- returnstring.replace("enum", "<FONT COLOR=RED>enum</FONT>");
- returnstring.replace("goto", "<FONT COLOR=RED>goto</FONT>");
- returnstring.replace("if", "<FONT COLOR=RED>if</FONT>");
- returnstring.replace("implements", "<FONT COLOR=RED>implements</FONT>");
- returnstring.replace("import", "<FONT COLOR=RED>import</FONT>");
- returnstring.replace("instanceof", "<FONT COLOR=RED>instanceof</FONT>");
- returnstring.replace("int", "<FONT COLOR=RED>int</FONT>");
- returnstring.replace("interface", "<FONT COLOR=RED>interface</FONT>");
- returnstring.replace("long", "<FONT COLOR=RED>long</FONT>");
- returnstring.replace("native", "<FONT COLOR=RED>native</FONT>");
- returnstring.replace("new", "<FONT COLOR=RED>new</FONT>");
- returnstring.replace("package", "<FONT COLOR=RED>package</FONT>");
- returnstring.replace("private", "<FONT COLOR=RED>private</FONT>");
- returnstring.replace("protected", "<FONT COLOR=RED>protected</FONT>");
- returnstring.replace("return", "<FONT COLOR=RED>return</FONT>");
- returnstring.replace("short", "<FONT COLOR=RED>short</FONT>");
- returnstring.replace("static", "<FONT COLOR=RED>static</FONT>");
- returnstring.replace("super", "<FONT COLOR=RED>super</FONT>");
- returnstring.replace("switch", "<FONT COLOR=RED>switch</FONT>");
- returnstring.replace("synchronized", "<FONT COLOR=RED>synchronized</FONT>");
- returnstring.replace("this", "<FONT COLOR=RED>this</FONT>");
- returnstring.replace("throws", "<FONT COLOR=RED>throws</FONT>");
- returnstring.replace("transient", "<FONT COLOR=RED>transient</FONT>");
- returnstring.replace("try", "<FONT COLOR=RED>try</FONT>");
- returnstring.replace("void", "<FONT COLOR=RED>void</FONT>");
- returnstring.replace("volatile", "<FONT COLOR=RED>volatile</FONT>");
- returnstring.replace("white", "<FONT COLOR=RED>white</FONT>");
- if (returnstring.charAt(0) == '/'){
- if (returnstring.charAt(1) == '/'){
- returnstring = "<FONT COLOR=GREEN>" + returnstring + "</FONT>";
- }
- else if(returnstring.charAt(1) == '*'){
- returnstring = "<FONT COLOR=GREEN>" + returnstring;
- for (int i = 0; i < 10;){
- returnstring = input.next();
- if (returnstring.charAt(holder) == '/'){
- if (returnstring.charAt(holder - 1) == '*'){
- returnstring = returnstring + "</FONT>";
- i = 10;
- }
- }
- }
- }
- }
- else if(returnstring.indexOf('"') != -1){
- returnstring = returnstring.substring(0, returnstring.indexOf('"')) + "<FONT COLOR=BLUE>" + returnstring.substring(returnstring.lastIndexOf('"')) + "</FONT>";
- }
- else if (returnstring.indexOf("'") != -1){
- returnstring = returnstring.substring(0, returnstring.indexOf("'")) + "<FONT COLOR=BLUE>" + returnstring.substring(returnstring.lastIndexOf("'")) + "</FONT>";
- }
- for (int i = 0; i < holder; i++){
- if (isDigit(returnstring.charAt(i))){
- }
- }
- }
- }
- private boolean isDigit(char charAt) {
- boolean isdigit = false;
- if (charAt == 0){
- isdigit = true;
- }
- else if(charAt == 1){
- isdigit = true;
- }
- else if(charAt == 2){
- isdigit = true;
- }
- else if(charAt == 3){
- isdigit = true;
- }
- else if(charAt == 4){
- isdigit = true;
- }
- else if(charAt == 5){
- isdigit = true;
- }
- else if(charAt == 6){
- isdigit = true;
- }
- else if(charAt == 7){
- isdigit = true;
- }
- else if(charAt == 8){
- isdigit = true;
- }
- else if(charAt == 9){
- isdigit = true;
- }
- return isdigit;
- }
- }