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,
Qt Code:
  1. FileInputStream fis;
  2. BufferedInputStream bis = null;
  3. try {
  4. fis = new FileInputStream( fileName );
  5. bis = new BufferedInputStream(fis);
  6. int i;
  7. while ((i = bis.read()) != -1) {
  8. if ( (char)i == '<' )
  9. System.out.print( (char)i );
  10. }
  11. fis.close();
  12. } catch (Exception e) {
  13. System.out.print("Exception: " + e);
  14. }
To copy to clipboard, switch view to plain text mode