Java Array Join join(String[] strings, String glue)

Here you can find the source of join(String[] strings, String glue)

Description

join

License

Open Source License

Declaration

public static String join(String[] strings, String glue) 

Method Source Code

//package com.java2s;
// "{ configData : { idDataset : \"primoID\", \"tenant\" : \"iotnet\", \"collection\" : \"provaAle\", \"database\": \"db\", \"type\" : \"dataset\", \"subtype\" : \"bulkDataset\", \"entityNameSpace\" : \"it.csi.smartdata.odata.iotnet.iotnetapi002\", \"datasetversion\" : \"1.0.0\", \"current\" : 1, \"archive\" : { \"archiveCollection\" : \"altraCollection\", \"archiveDatabase\": \"altroDB\",  \"archiveInfo\": [ { \"archiveRevision\": 1, \"archiveDate\" : null }, { \"archiveRevision\": 2, \"archiveDate\" : null } ]    }          }, \"metadata\" : { \"name\" : \"primodato\", \"description\" : \"Descrizione\", \"license\" : \"CC BY 4.0\", \"disclaimer\" : null, \"copyright\" : \"Copyright (C) 2014, CSP Innovazione nelle ICT. All rights reserved.\", \"visibility\" : \"public\", \"registrationDate\" : null, \"requestorName\" : \"nomeRichiedente\", \"requestorSurname\" : \"cognomeRichiedente\", \"dataDomain\" : \"ENVIRONMENT\", \"requestornEmail\" : \"ciao@email.it\", \"fps\" : 22,  \"startIngestionDate\" : null, \"endIngestionDate\" : null, \"importFileType\" : \"CSV\", \"datasetStatus\": \"Ok\",  \"tags\" : [{ \"tagCode\" : \"AIR\" }, { \"tagCode\" : \"INDOOR\" }, { \"tagCode\" : \"POLLUTION\" }, { \"tagCode\" : \"QUALITY\" } ], \"fields\" : [{ \"fieldName\" : \"campo_1\", \"fieldAlias\" : \"semantica campo 1\", \"dataType\" : \"int\", \"sourceColumn\" : \"1\", \"isKey\" : 0, \"measureUnit\" : \"ppm\" }, { \"fieldName\" : \"campo_2\", \"fieldAlias\" : \"semantica campo 2\", \"dataType\" : \"string\", \"sourceColumn\" : \"2\", \"isKey\" : 0, \"measureUnit\" : \"metri\" } ] } }";

import java.util.List;

public class Main {
    public static String join(String[] strings, String glue) {

        String result = "";
        if (glue == null)
            glue = ",";

        if (strings != null) {
            int counter = 0;
            for (String s : strings) {
                result += s;//w ww  . ja  va2s  .  c o m
                counter++;
                if (counter < strings.length)
                    result += glue;
            }
        }
        return result;
    }

    public static String join(List<Object> objectList, String glue) {

        String out = "";
        int counter = 0;
        if (objectList != null) {
            for (Object o : objectList) {
                if (o instanceof String)
                    out += o;
                else
                    out += o.toString();
                if (counter < objectList.size() - 1)
                    out += glue;
                counter++;
            }
        }
        return out;
    }
}

Related

  1. join(String[] stringArray, String delimiterString, boolean joinNullValues)
  2. join(String[] stringArray, String separator)
  3. join(String[] strings)
  4. join(String[] strings, char delimiter)
  5. join(String[] strings, char delimiter)
  6. join(String[] strings, String glue)
  7. join(String[] strings, String separator)
  8. join(String[] strings, String separator)
  9. join(String[] strings, String seperator)