想要提取出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的m
从字幕文件中提取英文原文
最新推荐文章于 2024-08-05 02:53:28 发布
本文介绍如何使用Java程序从ASS字幕文件中提取英文原文。通过读取文件行并查找特定字符串来实现这一功能。主要涉及的Java知识点包括IO包的使用、main方法、readFileByLines函数以及indexOf和substring方法的应用。程序员需要像在游戏LOL中记住每个英雄的技能一样,熟悉并灵活运用这些函数。

最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



