Java String Truncate truncateMessageIn50000Characters(final String message)

Here you can find the source of truncateMessageIn50000Characters(final String message)

Description

truncate Message In Characters

License

EUPL

Declaration

public static String truncateMessageIn50000Characters(final String message) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Digital Signature Applet//from  w w  w.  j a v a 2 s .c o  m
 *
 *  Copyright (C) 2014 European Commission, Directorate-General for Justice (DG  JUSTICE), B-1049 Bruxelles/Brussel
 *
 *  Developed by: ARHS Developments S.A. (rue Nicolas Bov? 2B, L-1253 Luxembourg)
 *
 *  http://www.arhs-developments.com
 *
 *  This file is part of the "Digital Signature Applet" project.
 *
 *  Licensed under the EUPL, version 1.1 or ? as soon they are approved by the European  Commission - subsequent versions of the EUPL (the "Licence").
 *  You may not use this  work except in compliance with the Licence. You may obtain a copy of the Licence at:
 *
 *  http://ec.europa.eu/idabc/eupl.html
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under   the Licence is distributed on
 *  an "AS IS" basis, WITHOUT WARRANTIES OR   CONDITIONS OF ANY KIND, either  express or implied.
 *
 *  See the Licence for the  specific language governing permissions and limitations under the Licence.
 ******************************************************************************/

public class Main {
    public static String truncateMessageIn50000Characters(final String message) {
        return truncateMessageInCharacters(message, 50000);
    }

    public static String truncateMessageInCharacters(final String message, int maxNumberOfCharacters) {
        if (message == null || message.length() == 0) {
            return message;
        }

        //Only truncate if the length is higher than the max allowed.
        if (message.length() > maxNumberOfCharacters) {
            return message.substring(0, maxNumberOfCharacters);
        }

        return message;
    }
}

Related

  1. truncateLabel(String label)
  2. truncateLeadingSlash(String uri)
  3. truncateLongName(String name, int nameLength)
  4. truncateLongStr(String str)
  5. truncateMessage(String message, int TRUNCATED_MSG_SIZE)
  6. truncateName(String name)
  7. truncateName(String name)
  8. truncateNicely(String s, int n, String suffix)
  9. truncateNicely(String str, int lower, int upper, String appendToEnd)