从字幕文件中提取英文原文

想要提取出cyber的字幕文件用来学习英语口语,用搜索引擎搜索到ass文件,然后利用一小段程序实现这个功能。import java.io.File;import java.io.IOException;import java.io.Reader;import java.io.InputStreamReader;import java.io.*;public class cyber {public static void main(String[] args) {readFileByLines("C:\\Users\\Administrator\\Desktop\\cyber subtitle\\13.ass");}public static void readFileByLines(String fileName) {File file = new File(fileName);BufferedReader reader = null;try {System.out.println("以行为单位读取文件内容,一次读一行");reader = new BufferedReader(new FileReader(file));String tempString = null;int line = 1;// 一次读一行,读入null时文件结束while ((tempString = reader.readLine()) != null) {// 把当前行号显示出来try {if (tempString.indexOf("{\\shad1}", 0) != -1) {tempString = tempString.substring(tempString.indexOf("{\\shad1}", 0) + 8);System.out.println(tempString);line++;}} catch (Exception e) {}}reader.close();} catch (IOException e) {e.printStackTrace();} finally {if (reader != null) {try {reader.close();} catch (IOException e1) {}}}}}用到的知识点:1导入java的io系统包2写java的main函数3写函数readfilebylines4用到了两个函数 tempstring.indexof 和tempstring.substring the method of the founction as follows indexof:http://blog.csdn.net/kyfg27_niujin/article/details/7778263substring:String str;str=str.substring(int beginIndex);截取掉str从首字母起长度为beginIndex的字符串,将剩余字符串赋值给str;str=str.substring(int beginIndex,int endIndex);截取str中从beginIndex开始至endIndex结束时的字符串,并将其赋值给str;http://www.jb51.net/article/46629.htmI feel that the founction in the programing is like to the skill in the computer game lol.every hero has his owm skill and use. promgramer should memory the skills of the founctions, when they are needed.

你可能感兴趣的:(从字幕文件中提取英文原文)