Compare a char using equals

前端 未结 3 961
悲哀的现实
悲哀的现实 2021-01-28 21:53

If I am scanning from a text

Scanner s= new Scanner(\"texto.txt\");

// I want to compare the next char from the line with a <

3条回答
  •  后悔当初
    2021-01-28 22:04

          FileReader reader = null;
      try {
         reader = new FileReader("");
         int ch = reader.read() ; 
         while (ch != -1) {
            // check for your char here
         }
      } catch (FileNotFoundException ex) {
         //
      } catch (IOException ex) {
         //
      } finally {
         try {
            reader.close();
         } catch (IOException ex) {
            //
         }
      }
    

提交回复
热议问题