Do I always need to escape metacharacters in a string that is not a “literal”?

Use Pattern.quote(String):

public static String quote(String s)

Returns a literal pattern String for the specified String.

This method produces a String that can be used to create a Pattern that would match the string s as if it were a literal pattern.

Metacharacters or escape sequences in the input sequence will be given no special meaning.

    s - The string to be literalized
    A literal string replacement


You can use


to escape meta characters used by regular expressions.


There are 3 different ways to get data out of a Blob column: getBytes getBinaryStream getBlob Also, the Blob object returned by getBlob also has a getBytes and getBinaryStream on it. Are there any ...

I was studying about bluetooth and I was trying to write the code to keep listening to the input stream while connected and i came across this following code snippet: int data =; ...

Some time ago I asked this question. All solutions are workarounds. Now this can't be. I feel that something is wrong here, but I can't tell if it is Swing's MVC model that is conceptually wrong, or ...

In onCreate() method of activity I have this code for ToolBar: toolbar = (Toolbar) findViewById(; setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); ...