Hello JavaGurus, I need to know if everyfile I read in has a 'Z' contained within the last line of the file. in particular it is the 10th byte from the EOF, but each file is different in length, so I'm using the .length() to get the total size but how would I say sBuffer.length() - 10 , then get the charAt() to check if it is a 'Z' thanks for anyone's help
import java.io.*;
import java.util.*;
public class injRecFix{
static PrintWriter prntWrter;
public static void main(
String[] args){
char[] chBuffer =null;
boolean bReadFile = false;
String sINFileName = null;
String sOUTFileName = null;
int i;
InputStream fin;
File outputFile = new File("newPunchFile.txt");
if(sINFileName == null)
sINFileName = "Punch.001";
try {
fin = new FileInputStream(sINFileName);
prntWrter = new PrintWriter(new FileWriter(outputFile));
} catch (IOException except) {
sINFileName = "Punch.001";
try {
fin = new FileInputStream(sINFileName);
} catch (IOException eIO) {
fin = null;
}
}
if(fin != null) { // dumping PunchFile into chBuffer
try {
chBuffer = new char[fin.available()];
int iC = 0;
while(iC < chBuffer.length) {
i = fin.read();
chBuffer[iC] = (char)i;
iC++;
}
fin.close();
bReadFile = true;
} catch (IOException except) {
bReadFile = false;
}
}
if (bReadFile) {
// Convert buffer into a string.
String sBuffer = new String(chBuffer, 0, chBuffer.length);
sBuffer.charAt(??)
//System.out.println(sBuffer.length());
}
}//end main()
}//end class injRecFix