Search in sources :

Example 51 with FileReader

use of java.io.FileReader in project Truck-Factor by aserg-ufmg.

the class Alias method readFile.

private static Alias[] readFile(String fileName) throws IOException {
    List<Alias> fileAliases = new ArrayList<Alias>();
    BufferedReader br = new BufferedReader(new FileReader(fileName));
    LineReader lineReader = new LineReader(br);
    String sCurrentLine;
    String[] values;
    int countcfs = 0;
    while ((sCurrentLine = lineReader.readLine()) != null) {
        values = sCurrentLine.split(";");
        if (values.length < 3)
            System.err.println("Erro na linha " + countcfs);
        String rep = values[0];
        String dev1 = values[1];
        String dev2 = values[2];
        fileAliases.add(new Alias(rep, dev1, dev2));
        countcfs++;
    }
    return fileAliases.toArray(new Alias[0]);
}
Also used : LineReader(com.google.common.io.LineReader) ArrayList(java.util.ArrayList) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader)

Example 52 with FileReader

use of java.io.FileReader in project Truck-Factor by aserg-ufmg.

the class FileInfoReader method getFileInfo.

public static Map<String, List<LineInfo>> getFileInfo(String fileName) throws IOException {
    Map<String, List<LineInfo>> fileInfoMap = new HashMap<String, List<LineInfo>>();
    BufferedReader br = new BufferedReader(new FileReader(fileName));
    LineReader lineReader = new LineReader(br);
    String sCurrentLine;
    String[] values;
    int countcfs = 0;
    while ((sCurrentLine = lineReader.readLine()) != null) {
        if (sCurrentLine.startsWith("#"))
            continue;
        values = sCurrentLine.split(";");
        if (values.length < 3)
            System.err.println("Erro na linha " + countcfs);
        String rep = values[0];
        if (!fileInfoMap.containsKey(rep)) {
            fileInfoMap.put(rep, new ArrayList<LineInfo>());
        }
        fileInfoMap.get(rep).add(new LineInfo(rep, Arrays.asList(values).subList(1, values.length)));
    }
    //lineReader.close();
    return fileInfoMap;
}
Also used : HashMap(java.util.HashMap) LineReader(com.google.common.io.LineReader) BufferedReader(java.io.BufferedReader) List(java.util.List) ArrayList(java.util.ArrayList) FileReader(java.io.FileReader)

Example 53 with FileReader

use of java.io.FileReader in project Truck-Factor by aserg-ufmg.

the class FileInfoExtractor method execute.

public List<NewFileInfo> execute() throws Exception {
    List<NewFileInfo> files = new ArrayList<NewFileInfo>();
    try {
        LOGGER.info(repositoryName + ": Extracting file information...");
        BufferedReader br = new BufferedReader(new FileReader(repositoryPath + fileName));
        String sCurrentLine;
        while ((sCurrentLine = br.readLine()) != null) {
            files.add(new NewFileInfo(repositoryName, sCurrentLine));
        }
        br.close();
    } catch (Exception e) {
        throw new Exception("Error in project " + repositoryName, e);
    }
    return files;
}
Also used : ArrayList(java.util.ArrayList) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) IOException(java.io.IOException) NewFileInfo(aserg.gtf.model.NewFileInfo)

Example 54 with FileReader

use of java.io.FileReader in project Truck-Factor by aserg-ufmg.

the class GitLogExtractor method insertFiles.

private void insertFiles(String projectName, Map<String, LogCommitInfo> mapCommit) throws IOException {
    LOGGER.info(projectName + ": Extracting logCommitFiles...");
    BufferedReader br = new BufferedReader(new FileReader(repositoryPath + "commitfileinfo.log"));
    String sCurrentLine;
    String[] values;
    while ((sCurrentLine = br.readLine()) != null) {
        values = sCurrentLine.split(";");
        String sha = values[0];
        LogCommitInfo commit = mapCommit.get(sha);
        commit.addCommitFile(new LogCommitFileInfo(commit, values[1], values[2], values[3]));
    }
    br.close();
}
Also used : LogCommitFileInfo(aserg.gtf.model.LogCommitFileInfo) LogCommitInfo(aserg.gtf.model.LogCommitInfo) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader)

Example 55 with FileReader

use of java.io.FileReader in project h2o-3 by h2oai.

the class H2OBuildVersion method calcBuildNumber.

private String calcBuildNumber(File rootDir, String versionFromGradle) {
    try {
        String buildNumberFileName = rootDir.toString() + File.separator + "gradle" + File.separator + "buildnumber.properties";
        File f = new File(buildNumberFileName);
        if (!f.exists()) {
            return "99999";
        }
        BufferedReader br = new BufferedReader(new FileReader(buildNumberFileName));
        String line = br.readLine();
        while (line != null) {
            Pattern p = Pattern.compile("BUILD_NUMBER\\s*=\\s*(\\S+)");
            Matcher m = p.matcher(line);
            boolean b = m.matches();
            if (b) {
                br.close();
                String buildNumber = m.group(1);
                return buildNumber;
            }
            line = br.readLine();
        }
        throw new RuntimeException("BUILD_NUMBER property not found in " + buildNumberFileName);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : Pattern(java.util.regex.Pattern) RuntimeException(java.lang.RuntimeException) Matcher(java.util.regex.Matcher) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) File(java.io.File) RuntimeException(java.lang.RuntimeException)

Aggregations

FileReader (java.io.FileReader)1873 BufferedReader (java.io.BufferedReader)1289 IOException (java.io.IOException)893 File (java.io.File)811 FileNotFoundException (java.io.FileNotFoundException)304 ArrayList (java.util.ArrayList)274 Test (org.junit.Test)197 FileWriter (java.io.FileWriter)148 HashMap (java.util.HashMap)116 Reader (java.io.Reader)99 BufferedWriter (java.io.BufferedWriter)98 Properties (java.util.Properties)66 InputStreamReader (java.io.InputStreamReader)64 LineNumberReader (java.io.LineNumberReader)61 Matcher (java.util.regex.Matcher)61 Map (java.util.Map)59 List (java.util.List)56 PrintWriter (java.io.PrintWriter)51 StringTokenizer (java.util.StringTokenizer)51 HashSet (java.util.HashSet)50