/**
* Copyright 2016 JustWayward Team
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.justwayward.reader.utils;
/**
* Created by lfh on 2016/9/10.
*/
public class StringUtils {
public static String creatAcacheKey(Object... param) {
String key = "";
for (Object o : param) {
key += "-" + o;
}
return key.replaceFirst("-","");
}
/**
* 格式化小说内容。
* <p/>
* <li>小说的开头,缩进2格。在开始位置,加入2格空格。
* <li>所有的段落,缩进2格。所有的\n,替换为2格空格。
*
* @param str
* @return
*/
public static String formatContent(String str) {
str = str.replaceAll("[ ]*", "");//替换来自服务器上的,特殊空格
str = str.replaceAll("[ ]*", "");//
str = str.replace("\n\n", "\n");
str = str.replace("\n", "\n" + getTwoSpaces());
str = getTwoSpaces() + str;
// str = convertToSBC(str);
return str;
}
/**
* Return a String that only has two spaces.
*
* @return
*/
public static String getTwoSpaces() {
return "\u3000\u3000";
}
}