Here you can find the source of csvEncode(int value)
Parameter | Description |
---|---|
value | the value. |
public static String csvEncode(int value)
//package com.java2s; public class Main { private static final String ENCLOSURE = "\""; private static final String EMPTY = ""; /**//from www .j av a 2s. c om * Encodes the given value to a CSV acceptable value. Returns the empty string * if argument is null. * * @param value the value. * @return the CSV encoded value. */ public static String csvEncode(int value) { return csvEncode(String.valueOf(value)); } /** * Encodes the given value to a CSV acceptable value. Returns the empty string * if argument is null. * * @param value the value. * @return the CSV encoded value. */ public static String csvEncode(String value) { if (value == null) { value = EMPTY; } else { value = value.replaceAll(ENCLOSURE, ENCLOSURE + ENCLOSURE); value = ENCLOSURE + value + ENCLOSURE; } return value; } /** * Encodes the given value to a CSV acceptable value. Returns the empty string * if argument is null. * * @param value the value. * @return the CSV encoded value. */ public static String csvEncode(Object value) { return value != null ? csvEncode(String.valueOf(value)) : EMPTY; } }