java - 如何在 Java 中将一些文本数据添加到视频文件中
问题描述
我想将一些字符串数据添加到视频文件中,但我不希望视频文件损坏。我想要实现的是:- 1.)将文本添加到视频文件中。2.) 从该视频文件中提取文本。
我尝试的是:-
public class VideoData{
public static void main(String[] args) {
//create file object
File file = new File("I:/java/MyFolder/SmallVideo.mp4");
try
{
//create FileInputStream object
FileInputStream fin = new FileInputStream(file);
byte fileContent[] = new byte[(int)file.length()];
fin.read(fileContent);
//create string from byte array
String strFileContent = new String(fileContent);
System.out.println("File content : ");
System.out.println(strFileContent);
File dest=new File("I://java//OtherFolder//SmallVideo.mp4");
BufferedWriter bw=new BufferedWriter(new FileWriter(dest));
bw.write(strFileContent + "\nThis is my Text");
bw.flush();
}
catch(FileNotFoundException e)
{
System.out.println("File not found" + e);
}
catch(IOException ioe)
{
System.out.println("Exception while reading the file " + ioe);
}
}
}
请帮助我完成上述任务。
解决方案
推荐阅读
- python - 在没有 shell=True 的情况下使用 python 运行外部程序?
- java - org.postgresql.jdbc.PgResultSet 实例和 io.vertx.core.impl.VertxThread 的内存泄漏
- javascript - 单击动态复选框时的操作
- wso2 - 打开 api 到芭蕾舞演员自动源代码生成时出错
- python - 为什么 multiprocessing.Pool 不启动?对于带有一些处理的简单 I/O 案例
- tensorflow - TensorFlow 使用 Kubernetes 为 OOMKilled 或 Evicted pod 提供服务
- javascript - 错误:请求失败,状态码为 400。在 POSTMAN 和应用程序中发送之间的差异
- javascript - InnerHTML 更新有效,但不在移动模式下呈现
- php - 选择查询以检查 SQL 数据库中的重叠日期,然后更改状态
- c - 从不同目录编译相同的 c 程序会生成不同大小的目标代码