Android examples for XML:XML Tag
Builds XML end tag with name provided.
/*//from w w w. ja v a 2 s . c o m * Copyright 2016-present Open Networking Laboratory * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ //package com.java2s; public class Main { public static void main(String[] argv) { String name = "java2s.com"; System.out.println(buildEndTag(name)); } public static final String SLASH = "/"; public static final String NEW_LINE = "\n"; public static final String ANGLE_LEFT = "<"; public static final String ANGLE_RIGHT = ">"; /** * Builds XML end tag with name provided. * * @param name tag name * @return string */ public static String buildEndTag(String name) { return buildEndTag(name, true); } /** * Builds XML end tag with name provided. * * @param name tag name * @param addNewLine option to add new line character after tag * @return string */ public static String buildEndTag(String name, boolean addNewLine) { if (addNewLine) { return (ANGLE_LEFT + SLASH + name + ANGLE_RIGHT + NEW_LINE); } else { return (ANGLE_LEFT + SLASH + name + ANGLE_RIGHT); } } }