I am reading a piece code as below:
private String loadAsString(final String path) {
try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(path);
Scanner scanner = new Scanner(inputStream)) {
// '\\A' is the delimiter of .sql file?
return scanner.useDelimiter("\\A").next();
} catch (IOException e) {
throw new RuntimeException("Unable to close input stream.", e);
}
}
where path = "***.sql", which means an SQL file on my computer.
My question is why the pattern "\A" is used as the delimiter to end the reading of the SQL file? As I know, "\A" is the regex of Java for the beginning of an input but not the ending. Thanks for help.