Java String Quote quote(String path)

Here you can find the source of quote(String path)

Description

quote

License

Apache License

Declaration

public static String quote(String path) 

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

public class Main {
    public static String quote(String path) {
        String result = path;/*w ww .  jav a2s.c o  m*/

        if (path.isEmpty() || path.indexOf(' ') == -1) {
            final StringBuilder builder = new StringBuilder();
            builder.append('\'');

            for (int i = 0; i < path.length(); i++) {
                char chr = path.charAt(i);

                if (chr == '\'') {
                    builder.append("\'");
                } else {
                    builder.append(chr);
                }
            }

            builder.append('\'');
            result = builder.toString();
        }

        return result;
    }

    public static boolean isEmpty(String s) {
        return s == null || s.isEmpty();
    }
}

Related

  1. quote(String name)
  2. quote(String name)
  3. quote(String name)
  4. quote(String p_sql)
  5. quote(String p_string)
  6. quote(String s)
  7. quote(String s)
  8. quote(String s)
  9. quote(String s)