Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.Scanner;
- public class Test {
- public static void main(String[] args) throws Exception {
- String filename = args[0];
- Test rTest = new Test();
- rTest.throeException(rTest.readFile(filename));
- }
- public void throeException(String strE){
- if(strE.contains("s") || strE.contains("u") || strE.contains("m") || strE.contains("a") || strE.contains("n") ){
- throw new IllegalArgumentException();
- }
- }
- public String readFile(String file)
- {
- System.out.println(file);
- StringBuilder stringBuilder = new StringBuilder();
- Scanner scan;
- try {
- scan = new Scanner(new File(file));
- while (scan.hasNextLine()){
- stringBuilder.append(scan.nextLine());
- }
- scan.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- return stringBuilder.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement