|
|
@@ -12,9 +12,16 @@ public class SpecialCharDocument extends Document {
|
|
12
|
12
|
|
|
13
|
13
|
@Override
|
|
14
|
14
|
public void write(String contentToBeWritten) {
|
|
|
15
|
+ try {
|
|
|
16
|
+ isSpecialCharacters(contentToBeWritten);
|
|
|
17
|
+ super.write(contentToBeWritten);
|
|
|
18
|
+ } catch (IOException e) {
|
|
|
19
|
+ e.printStackTrace();
|
|
|
20
|
+ }
|
|
15
|
21
|
}
|
|
16
|
22
|
|
|
17
|
|
- private Boolean isSpecialCharacters(String s) {
|
|
18
|
|
- return null;
|
|
|
23
|
+ private void isSpecialCharacters(String s) throws IOException {
|
|
|
24
|
+ if(!s.matches("[\\W_]*"))
|
|
|
25
|
+ throw new IllegalArgumentException();
|
|
19
|
26
|
}
|
|
20
|
27
|
}
|