Reading pins in Java

I am trying to read an analog pin with java on the Beaglebone (A6 - running Angstrom). When I type “cat /sys/devices/platform/omap/tsc/ain6” when ssh-ed in I get a number. But when I compile the code below on the Beaglebone and run it I get NULLs. Am I opening or reading from the location in the wrong way?

I additionally want to be able to set some digital pins (as I can in cloud9) so as to control a multiplexer. I have searched and found very little information for Java that reads/writes the pins on Beaglebone. Is there anywhere with examples of doing this sort of thing?


class matrix_test {

//AnalogRead: /sys/devices/platform/omap/tsc/ain6
public static void main(String[] args) {

System.out.println(“Starting matrix_test”);
try {
FileInputStream analog = new FileInputStream("/sys/devices/platform/omap/tsc/ain6");
DataInputStream in = new DataInputStream(analog);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;

//Read File Line By Line
while (true) {
strLine = br.readLine();
// Print the content on the console
catch (Exception e) { //Catch exception if any
System.err.println("Error: " + e.getMessage());
//Close the input stream

I have been doing this and you have to cycle open/close the file in between each read. Same as with GPIO lines.