.
as a regex pattern JAVA-W1078A single unescaped .
in a regex pattern will match one of any character, not just the period character.
Consider escaping the .
if you meant to match a single period instead.
This regex matches anything but newlines, once:
Pattern p = Pattern.compile(".");
Escape the pattern with two \
characters if you are matching a single period.
Pattern p = Pattern.compile("\\.");