📄 utils.java
字号:
/**
Copyright (C) 2002-2003 Together
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.webdocwf.util.loader.generator;
/**
* Utility methods for csv jdbc.
*
* @author Zoran Milakovic
*/
public class Utils {
/**
* Replace all occurence of forReplace with replaceWith in input string.
* @param input
* @param forReplace
* @param replaceWith
* @return new string with replaced values
*/
public static String replaceAll(String input, String forReplace,
String replaceWith) {
StringBuffer result = new StringBuffer();
boolean hasMore = true;
while (hasMore) {
int start = input.indexOf(forReplace);
int end = start + forReplace.length();
if (start != -1) {
result.append(input.substring(0, start) + replaceWith);
input = input.substring(end);
}
else {
hasMore = false;
result.append(input);
}
}
if (result.toString().equals(""))
return input; //nothing is changed
else
return result.toString();
}
public static String handleQuotedString(String quotedString) {
String retVal = quotedString;
if ( (retVal.startsWith("'") && retVal.endsWith("'"))) {
if (!retVal.equals("''")) {
retVal = retVal.substring(retVal.indexOf("'") + 1,
retVal.lastIndexOf("'"));
}
else {
retVal = "";
}
}
return retVal;
}
public static String[] replaceLineBrakesAndCarrReturn(
String[] toReplace,
String lineBreakEscape,
String carriageReturnEscape) {
String[] retVal = new String[toReplace.length];
for (int i = 0; i < toReplace.length; i++) {
if (toReplace[i] != null) {
retVal[i] = replaceAll(toReplace[i], "\n", lineBreakEscape);
retVal[i] = replaceAll(retVal[i], "\r", carriageReturnEscape);
}
}
return retVal;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -