public static void downloadHttpUrl(String url, String dir, String fileName) {
try {
URL httpurl = new URL(url);
File dirfile = new File(dir);
if (!dirfile.exists()) {
dirfile.mkdirs();
}
FileUtils.copyURLToFile(httpurl, new File(dir + fileName));
} catch (Exception e) {
e.printStackTrace();
}
读取log文件,一个一个词打印出来。
try {
BufferedReader in = new BufferedReader(new FileReader("/data/test.log"));
String str;
String str1;
String str2;
while ((str = in.readLine()) != null) {
str1= str.substring(0,str.indexOf(" ")+1);
System.out.println(str1);
System.out.println(str.substring(str.indexOf(" ")+1).trim());
}
System.out.println(str);
} catch (IOException e) {
}