Try this:
package LoopPb;
import java.io.*;
import java.util.*;
class AminoToken
{
//System.out.println("**Inside AminoToken");
public static void main (String args[])
{
//System.out.println("**Inside main");
char inChar;
long aminosSize;
char aminosAry[];
String aminosStr = "";
StringTokenizer aminosLn;
StringTokenizer aminosInf;
File aminos;
FileInputStream aminosIS;
//System.out.println("**References created");
try
{
//System.out.println("**Inside try block");
aminos = new File("aminos.txt");
//System.out.println("**File created");
aminosIS = new FileInputStream(aminos);
//System.out.println("**FileInputStream created");
aminosSize = aminos.length();
//System.out.println("**aminosSize intialized");
aminosAry = new char[(int)aminosSize];
//System.out.println("**aminosAry created");
for(int aminosAryInd = 0; aminosAryInd < aminosSize; aminosAryInd++)
{
aminosAry[aminosAryInd] = (char) aminosIS.read();
aminosStr += aminosAry[aminosAryInd];
System.out.print(aminosAry[aminosAryInd]);
}
}
catch (FileNotFoundException fnfe)
{
System.out.println(fnfe);
}
catch (IOException ioe)
{
System.out.print(ioe);
}
System.out.println(aminosStr);
}
}
You should parse file using while..loop, it's safer:
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class ReaddinFile {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
FileReader f = null;
try {
f = new FileReader("aminos.txt");
int c;
while ((c = f.read()) != -1) {
System.out.print((char) c);
}
} catch (FileNotFoundException fnfe) {
System.out.println("fis abs");
fnfe.printStackTrace();
} catch (IOException ioe) {
System.out.println("Read error");
ioe.printStackTrace();
} finally {
if (f != null) {
try {
f.close();
} catch (IOException ioe) {
System.out.println("Err inchidere fis");
ioe.printStackTrace();
}
}
}
}
}