Test001.java
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.espeed.text;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
public class Test001 {
/**
* @param args
*/
public static void main(String[] args) {
// Pattern p = Pattern.compile("^([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$");
// Matcher m = p.matcher("123.com.cn");
// if(!m.matches()){
// //不合法
// System.out.println("不行");
// }else{
// //合法
// System.out.println("行");
// }
try {
File file=new File("f://yes.txt");
BufferedReader br = new BufferedReader(new FileReader(file));//构造一个BufferedReader类来读取文件
String s = null;
String context = "";
while((s = br.readLine())!=null){//使用readLine方法,一次读一行
context =s;
}
br.close();
//System.out.println(result);
String[] picpath=context.split("<img src=\"");
int end=picpath[1].indexOf("\"");
String result=picpath[1].substring(0,end);
System.out.println(result);
int pathbegin=result.indexOf("mailtempfile");
String path=result.substring(pathbegin,result.length());
System.out.println(path);
//String[] filenamestr=result.split("/");
//System.out.println("文件名"+filenamestr[filenamestr.length-1]);
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
}
}