Java Utililty Methods BufferedReader Read

List of utility methods to do BufferedReader Read

Description

The list of methods to do BufferedReader Read are organized into topic(s).

Method

SetloadList(String listName)
load List
Set<String> list = new HashSet<String>();
File file = new File(listName);
if (file.exists()) {
    try (BufferedReader br = new BufferedReader(new FileReader(file))) {
        for (String line; (line = br.readLine()) != null;)
            list.add(line.trim().toLowerCase());
return list;
StringloadListFromTextFile(String filename, String defaultitem, String linePrefix, String lineSuffix)
Method loadListFromTextFile.
String result = "";
try {
    BufferedReader in = new BufferedReader(new FileReader(filename));
    String str;
    if (defaultitem != null) {
        result = result + linePrefix + defaultitem + lineSuffix;
    while ((str = in.readLine()) != null) {
...
long[]loadLongArray(BufferedReader in)
load Long Array
try {
    int dim = Integer.parseInt(in.readLine());
    String[] vals = in.readLine().split("\\s+");
    long[] ret = new long[dim];
    for (int i = 0; i < ret.length; i++) {
        ret[i] = Long.parseLong(vals[i]);
    return ret;
...
MaploadMetadata(File file)
load Metadata
StringBuilder metadataBuilder = new StringBuilder();
BufferedReader reader = new BufferedReader(new FileReader(file));
String line;
while ((line = reader.readLine()) != null) {
    metadataBuilder.append(line).append('\n');
reader.close();
Gson gson = new Gson();
...
ListloadMetaFile(File metaFile)
load Meta File
List<String> list = new ArrayList<String>();
FileReader fr;
try {
    fr = new FileReader(metaFile);
    BufferedReader reader = new BufferedReader(fr);
    String s = reader.readLine();
    while (s != null) {
        list.add(s);
...
voidloadMimeTypes(Reader in, Map extMap, Map mimeMap)
Parses a mime.types file, and generates mappings between MIME types and extensions.
BufferedReader br = new BufferedReader(in);
String line;
while ((line = br.readLine()) != null) {
    if (line.startsWith("#")) {
        continue;
    if (line.trim().length() == 0) {
        continue;
...
voidloadModel(String fileName, Hashtable dictionary, Hashtable> modelPairs)
load Model
BufferedReader reader = null;
try {
    reader = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "UTF-8"));
} catch (UnsupportedEncodingException e) {
    e.printStackTrace();
} catch (FileNotFoundException e) {
    e.printStackTrace();
String line = null;
try {
    while ((line = reader.readLine()) != null) {
        line = line.trim();
        if (line.length() == 0 || line.charAt(0) == '#')
            continue;
        String[] halves = line.split("=");
        String mm = halves[0].trim();
        String roman = halves[1].trim();
        dictionary.put(mm, roman);
        if (modelPairs != null) {
            if (!modelPairs.containsKey(roman))
                modelPairs.put(roman, new ArrayList<String>());
            modelPairs.get(roman).add(mm);
} catch (IOException ex) {
    ex.printStackTrace();
try {
    reader.close();
} catch (IOException ex) {
    ex.printStackTrace();
Map>loadNameMap(String mapName, boolean reverseMap)
load Name Map
Map<String, List<String>> rtrn = new HashMap<String, List<String>>();
String line;
BufferedReader br = new BufferedReader(new FileReader(mapName));
while ((line = br.readLine()) != null) {
    String[] lineSplit = line.split("\t");
    String n1 = lineSplit[0];
    String n2 = lineSplit[1];
    if (reverseMap) {
...
int[]loadNumUsers(String fileName)
load Num Users
File file = new File(fileName);
FileReader fileReader = new FileReader(file);
BufferedReader bufferedReader = new BufferedReader(fileReader);
String line;
try {
    if ((line = bufferedReader.readLine()) != null) {
        String[] tmp_res = line.split(" ");
        int[] res = new int[tmp_res.length];
...
MaploadPartitions(String fileName)
load Partitions
BufferedReader reader = new BufferedReader(new FileReader(fileName));
Map<Integer, Integer> result = new HashMap<Integer, Integer>();
String line;
while ((line = reader.readLine()) != null) {
    String[] tokens = line.split(" ");
    assert (tokens.length == 2);
    int lit = Integer.parseInt(tokens[0]);
    int partition = Integer.parseInt(tokens[1]);
...