Hello,
simple question. I'd like read a file char by char but I have to do some operation on this. I solve with a cast to char but I suppose it's slow. Which alternative does java language offer?
Thanks,
FileInputStream fis;
BufferedInputStream bis = null;
try {
fis = new FileInputStream( fileName );
bis = new BufferedInputStream(fis);
int i;
while ((i = bis.read()) != -1) {
if ( (char)i == '<' )
System.out.print( (char)i );
}
fis.close();
} catch (Exception e) {
System.out.print("Exception: " + e);
}
FileInputStream fis;
BufferedInputStream bis = null;
try {
fis = new FileInputStream( fileName );
bis = new BufferedInputStream(fis);
int i;
while ((i = bis.read()) != -1) {
if ( (char)i == '<' )
System.out.print( (char)i );
}
fis.close();
} catch (Exception e) {
System.out.print("Exception: " + e);
}
To copy to clipboard, switch view to plain text mode
Bookmarks