Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashSet;

public class Main {
    private static final String INTENT_GET_EXTRAS_METHODS = "config/IntentGetExtraMethods.txt";
    private static final String API_MISUSE_METHODS = "config/APIMisuseMethods.txt";
    private static final String ANDROID_CLASSES = "config/AndroidClassPrefixes.list";
    private static final String API_SINK_METHODS = "config/APISinkMethods.txt";
    private static HashSet<String> APISinkMethods = new HashSet<String>();
    private static HashSet<String> intentExtrasMethods = new HashSet<String>();
    private static HashSet<String> APIMisuseMethods = new HashSet<String>();
    private static HashSet<String> androidClassPrefixes = new HashSet<String>();

    public static void fromFile(String fileName) throws IOException {
        readFile(fileName);
    }

    private static void readFile(String fileName) throws IOException {
        String line;
        FileReader fr = null;
        BufferedReader br = null;
        try {
            fr = new FileReader(fileName);
            br = new BufferedReader(fr);
            while ((line = br.readLine()) != null) {

                if (line.isEmpty() || line.startsWith("%"))
                    continue;
                if (fileName.equals(INTENT_GET_EXTRAS_METHODS)) {
                    intentExtrasMethods.add(line);
                } else if (fileName.equals(API_MISUSE_METHODS)) {
                    APIMisuseMethods.add(line);
                } else if (fileName.equals(ANDROID_CLASSES)) {
                    androidClassPrefixes.add(line);
                } else if (fileName.equals(API_SINK_METHODS)) {
                    APISinkMethods.add(line);
                }
            }

        } finally {
            if (br != null)
                br.close();
            if (fr != null)
                fr.close();
        }
    }
}