Skip to content

Instantly share code, notes, and snippets.

@geofferyzh
Created October 2, 2012 15:34
Show Gist options
  • Save geofferyzh/3820212 to your computer and use it in GitHub Desktop.
Save geofferyzh/3820212 to your computer and use it in GitHub Desktop.
Hadoop 101 - Read a local file using bufferreader
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public static final String InitialActivationList = "/.../Initial_Activation_List.txt";
String toBeActivated;
public void loadInitialActivation(String InitialActivationList, int linenum_index) throws IOException {
String line;
int linenum = 0;
BufferedReader bufferedReader = new BufferedReader(new FileReader(InitialActivationList));
while ((line = bufferedReader.readLine()) != null) {
linenum = linenum + 1;
if (linenum == linenum_index) {
toBeActivated = line.toString();
break;
}
}
bufferedReader.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment