📄 util.java.svn-base
字号:
package GDPE.reports;
import java.util.ArrayList;
import java.util.Map;
import java.io.*;
//import com.fswan.db.TableClass;
public class Util {
public Util() {
}
public static String Replaceall(String source,String newstr,String oldstr)
{
int soucelen=source.length() ;
int newstrlen=newstr.length() ;
int oldlen =oldstr.length();
String returnstr=source;
String top="";
String end="";
while(returnstr.indexOf(oldstr)!=-1 )
{
top=returnstr.substring(0,returnstr.indexOf(oldstr) );
//System.out.println("top----"+top);
end=returnstr.substring(returnstr.indexOf(oldstr)+oldlen,returnstr.length() );
//System.out.println("end----"+end);
returnstr=top+newstr+end;
//System.out.println("newstr----"+newstr);
}
return returnstr;
}
//清除""号Tab特殊符号
public static String clearstr(String str)
{
int count=0;
String tempstr="";
String returnstr=str;
String top="";
String bottom="";
while (count<returnstr.length() ) {
if (returnstr.charAt(count)=='\"' || returnstr.charAt(count)=='\t')
{
tempstr=tempstr+str.charAt(count) ;
// System.out.println("tempstr is "+tempstr);
// System.out.println("first"+tempstr.substring(0,1));
if( bytab(tempstr,'\t') )
{
// System.out.println("tempstr is "+tempstr);
top= returnstr.substring(0,count) ;
bottom=returnstr.substring(count,returnstr.length()) ;
top= Replaceall(top,"","\"") ;
top= Replaceall(top,"","\t") ;
returnstr=top+bottom;
count=0;
}
}
count++;
}
returnstr=Replaceall(returnstr,"","\"");
return returnstr ;
}
public static boolean bytab(String tempstr,char ch )
{//判断是否符合" " 中间为n 个 ch 格式
boolean flag=false;
if(tempstr.charAt(0)=='\"'&&tempstr.charAt(tempstr.length()-1 )=='\"'&&tempstr.length() >2 )
{ flag=true;
for(int i=1;i<tempstr.length()-2;i++ )
{
if(tempstr.charAt(i)!=ch )
flag=false;
}
}
else
flag= false;
return flag;
}
//将指定间隔的字符分到 ArrayList中去
public static ArrayList Toarray(String str,char splitstr)
{
ArrayList alist = new ArrayList();
int count=0;
int from=0;
int end=0;
while (count<str.length() ) {
if (str.charAt(count)==splitstr )
{ from=end;
end=count;
if(from==0)
alist.add(str.substring(from,end) );
else
alist.add(str.substring(from+1,end) );
}
count++;
}
return alist ;
}
public static String ToISO(String str)
{
try {
return new String(str.getBytes("iso-8859-1"),"gb2312");
} catch (UnsupportedEncodingException ex) {
return null;
}
}
/**
* 1. 演示将流中的文本读入一个 StringBuffer 中
* @throws IOException
*/
public static void readToBuffer(StringBuffer buffer, InputStream is)
throws IOException {
String line; // 用来保存每行读取的内容
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
line = reader.readLine(); // 读取第一行
while (line != null) { // 如果 line 为空说明读完了
buffer.append(line); // 将读到的内容添加到 buffer 中
buffer.append("\n"); // 添加换行符
line = reader.readLine(); // 读取下一行
}
}
//public static void main(String[] args)
// {
// Util util = new Util();
// // String tempstr=util.clearstr("\"用合作社\t\t业部\" 0 0") ;
// // System.out.println(tempstr);
// // System.out.println("1: "+(tempstr.length() >2)+" 2: "+ tempstr.substring(1,2).equals("\t")+"3: "+tempstr.substring(tempstr.length()-1 ,tempstr.length()).equals("\t"));
// //System.out.println(util.Replaceall(" <td class=xl3511293>[#Top_1#]</td>","王八但","[#Top_1#]<") );
// System.out.println("ttt.xsl|".replace('|',' ').trim() );
// }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -