Pattern.compile takes a String as argument, if a BufferedReader reads a line with readLine() ir returns a String, So a Regex like hello\sworld read from a file
is passed in to Pattern.compile() it compiles fine and works fine in a Matcher to match text of "hello world" (without the quotes).

But using the same code in a String literal (as below) gives a compile failure (yes some literature does say the String class swallows the escapes in cases so therefore the need for double back slashing.

Exactly what you can have between the " signs in a String literal is described in the JLS 3.10.5 String Literals. In particular only certain things are allowed as escape sequences (listed in 3.10.6) and \s isn't one of them.

To expand a bit.
'\' is the escape character for Java Strings.
Since '\' marks certain commands in Regex, you need to escape the escape in order for it to be passed to regex and not treated as an escape sequence by the Java compiler. So '\\' gets translated by the compiler into a normal '\'.