escape Quote - Java java.lang

Java examples for java.lang:String Quote

Introduction

The following code shows how to escape Quote.

Demo Code

//package com.java2s;

public class Main {
    public static void main(String[] argv) {
        String s = "book\"2s.com";
        System.out.println(escapeQuote(s));
    }//from   w  w w.  jav  a2 s.  c  o  m

    public static String escapeQuote(String s) {
        return s.replaceAll("\"", "\\\"");
    }
}

Related Tutorials