「Java」テキスト文字列カンマをエスケープする
カンマのエスケープの構文
文字列 = “\""+文字列+"\"";
使用例
package com.arkgame.bat;
public class QoteseDemo {
// カンマのエスケープの文字列
private static final String ptn = "\"";
public static void main(String[] args) {
// カンマを含む文字列
String target = "test,123,addr";
if (target.contains(",")) {
// カンマ[,]のエスケープ
target = ptn + target + ptn;
}
System.out.println(target);
}
}
結果
“test,123,addr"