import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
public class Youtube
{
/**
* Keeps track of whether the first reading has been performed.
*/
protected boolean readFlag = false;
/*
* The main program, which can be executed from the command line
*/
public static void main(String [] args)
{
int liLine = 0;
int liDataIndex = 0;
ArrayList datalist = new ArrayList();
BufferedReader br = null;
int chkInt =0;
try {
br = new BufferedReader(new FileReader("D:\\htmlp\\eve.html"));
String line;
String title;
while ((line = br.readLine()) != null) {
if(line.indexOf("yt-uix-sessionlink yt-uix-tile-link spf-link yt-ui-ellipsis yt-ui-ellipsis-2") > 0)
{
title = line.substring(line.indexOf("title="),line.indexOf("aria-describedby"));
datalist.add(title);
System.out.println(title);
}
if(chkInt == 500) break; // 10 Line
chkInt ++;
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (br != null) {
br.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
try {
FileWriter writer = new FileWriter("eveOut.txt", true);
for(int i=0; i < datalist.size() ; i++) {
String outStr = (String)datalist.get(i);
writer.write(outStr);
writer.write("\r\n");
}
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
'세상이야기' 카테고리의 다른 글
자바 파일 읽고/쓰기 처리 소스 (0) | 2017.02.17 |
---|---|
Java File Read/Write 예제소스, 한글 깨지는 현상 해결 (0) | 2017.02.17 |
MySql 문자열 합치기 (0) | 2016.12.19 |
HTML Language Code Reference (0) | 2016.12.14 |
CKEditor(유료) (0) | 2016.12.04 |