|
|
@@ -1,14 +1,12 @@
|
|
1
|
1
|
package rocks.zipcode;
|
|
2
|
2
|
|
|
3
|
|
-import java.io.BufferedWriter;
|
|
4
|
|
-import java.io.FileWriter;
|
|
5
|
|
-import java.io.IOException;
|
|
|
3
|
+import java.io.*;
|
|
|
4
|
+import java.util.regex.Pattern;
|
|
6
|
5
|
|
|
7
|
6
|
/**
|
|
8
|
7
|
* @author leon on 16/11/2018.
|
|
9
|
8
|
*/
|
|
10
|
9
|
public class AlphaCharDocument extends Document {
|
|
11
|
|
- Document document;
|
|
12
|
10
|
|
|
13
|
11
|
public AlphaCharDocument(String fileName) throws IOException {
|
|
14
|
12
|
|
|
|
@@ -18,15 +16,24 @@ public class AlphaCharDocument extends Document {
|
|
18
|
16
|
|
|
19
|
17
|
@Override
|
|
20
|
18
|
public void write(String contentToBeWritten) throws IOException {
|
|
21
|
|
-
|
|
22
|
|
-
|
|
|
19
|
+ BufferedWriter writer = new BufferedWriter(new FileWriter("target/file.txt"));
|
|
|
20
|
+ writer.write(contentToBeWritten);
|
|
|
21
|
+ writer.close();
|
|
23
|
22
|
|
|
24
|
23
|
}
|
|
25
|
24
|
|
|
26
|
25
|
private Boolean isAlpha(String s) {
|
|
27
|
26
|
|
|
28
|
|
- boolean allLetters = s.chars().allMatch(Character::isLetter);
|
|
29
|
|
- return allLetters;
|
|
|
27
|
+// boolean allLetters = s.chars().allMatch(Character::isLetter);
|
|
|
28
|
+// return allLetters;
|
|
|
29
|
+
|
|
|
30
|
+
|
|
|
31
|
+// return (s.matches("[a-zA-Z]+"));
|
|
|
32
|
+
|
|
|
33
|
+ if(! Pattern.matches(".*[a-zA-Z]+.*", s))
|
|
|
34
|
+ return true;
|
|
|
35
|
+ else return false;
|
|
|
36
|
+
|
|
30
|
37
|
|
|
31
|
38
|
}
|
|
32
|
39
|
|