Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AlphabetTest {
- public static String FSAAcceptableCharacters = "abc";
- public static void main(String[] args) {
- String fileStr = returnFileContent();
- System.out.println(fileStr); // making sure we read the right file
- try {
- for(int i = 0; i < fileStr.length(); i++) {
- if(!Character.isLetter(fileStr.charAt(i))) { // alphabet test
- throw new Exception("Character '" + fileStr.charAt(i) + "' is not in the alphabet");
- }
- String s = "";
- if(FSAAcceptableCharacters.indexOf(s + fileStr.charAt(i)) == -1) {
- throw new Exception("Character '" + fileStr.charAt(i) + "' is not in the FSA accepting part of the alphabet");
- }
- }
- System.out.println("No faulty character found"); // in case no faulty characters are found
- } catch(Exception e) {
- System.out.println(e.getMessage()); // show the error in the console
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement