代码如下
String content = "";
int i=0,j=0;
boolean result = false;
content=content+ru.createGjOptionListForDoc();
//**
//*取出记录中的IMG路径存放入数组String path[n]中
//**
try {
Pattern p1 = Pattern.compile("(\\S+jpg)");
Matcher m1 = p1.matcher(content);
while(result = m1.find())
{
i++;
}
m1.reset();
String [] path = new String [i];
while(result = m1.find())
path[j++]=m1.group();
this.imgPath = path;
//System.out.println("图片个数"+path.length);
//System.out.println("图片个数"+imgPath.length);
//**
// * 替换记录中所有img的指向为当前目录以下载后查看
//**
Pattern p = Pattern.compile("/imgupload/");
Matcher m = p.matcher(content);
content = m.replaceAll(" ");
//生成文件名数组
Pattern p2 = Pattern.compile("(\\S+jpg)");
Matcher m2 = p2.matcher(content);
m2.reset();
System.out.println(content);
/*i=0;
while(result = m1.find())
i++;
m1.reset();*/
j=0;
String [] Name = new String [i];
while(result = m2.find())
{
Name[j++]=m2.group();
System.out.println(Name[j-1]);
}
System.out.println("图片名称个数"+Name.length);
this.imgName = Name;
} catch (Exception e) {
// TODO: handle exception
System.out.println(e);
}
取了相关的一段。记录下。
