Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.math.BigDecimal;

import java.util.Map;

public class Main {

    public static String[] mapToStringArray(Map<String, Object> map, String... keys) {
        String[] array = new String[keys.length];
        for (int i = 0; i < keys.length; i++) {
            String key = keys[i];
            Object value = map.get(key);
            String strValue = null;
            if (!map.containsKey(key)) {
                strValue = key;
            } else if (value == null) {
                strValue = "";
            } else if (value instanceof BigDecimal) {
                BigDecimal conv = (BigDecimal) value;
                strValue = conv.toPlainString();
            } else {
                strValue = value.toString();
            }
            array[i] = strValue;
        }
        return array;
    }
}