Você está na página 1de 2

e this template, choose Tools | Templates * and open the template in the editor.

*/ package reconhecedoresinteiros; /** * * @author fso.1811283419 */ import java.io.*; class reconhecedoresinteiros{ private String nomeArquivo; public FileReader bf; public static StringBuffer numero; public static void main(String[] args) throws IOException { reconhecedoresinteiros ri = new reconhecedoresinteiros("G:/temp/font.txt"); numero =new StringBuffer(); outer: while(true){ try{ char c = ri.LerCaractere();//ler o pr caracter da fila numero = new StringBuffer(); boolean ativa = true; while (ri.MecanismoReconhecimentoDec(c, ativa)) { numero.append(c); if(c == '.'){ ativa = false; } try{ c = ri.LerCaractere(); }catch (Exception e){ System.out.println(numero.toString()); break outer; } } if(numero.length()>0){ if(numero.charAt(numero.length()-1)=='.')numero.append("00"); } System.out.println(numero.toString());

}catch(Exception e){ break; } } }

public reconhecedoresinteiros(String nomeArquivo) throws IOException { bf = new FileReader(nomeArquivo); }

public char LerCaractere() throws IOException, Exception { char[] temp = new char [1]; int r =bf.read(temp); if (r < 0){ throw new Exception("Fim de Arquivo"); } return temp[0]; } public boolean MecanismoReconhecimentoInt(char c){ if (c == '(' || c == '1' ||c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9' || c == '0' || c == '.' || c == ')') { return true; } else { return false; }}

public boolean MecanismoReconhecimentoDec(char c, boolean ativa){ if (c == '(' || c == '1' ||c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9' || c == '0' || c == '.' || c == ')'){ return true; } else{ return MecanismoReconhecimentoInt(c); }} }

/** * @param args the command line arguments */

Você também pode gostar