当前位置: 首页 > news >正文

用struts2框架做的网站/长沙优化排名推广

用struts2框架做的网站,长沙优化排名推广,东胜网站建设,简洁网站布局复制视频文件文件。c:–》D:多线程:n个线程 一个文件比较大,分n部分进行复制 提示 RandomAccessFile //多线程实现同一文件复制 import java.io.File; import java.io.FileNotFoundException; import java.io.RandomAccessFile;p…

复制视频文件文件。c:–》D:多线程:n个线程
一个文件比较大,分n部分进行复制

提示 RandomAccessFile

//多线程实现同一文件复制
import java.io.File;
import java.io.FileNotFoundException;
import java.io.RandomAccessFile;public class F_13 {public static void main(String[] args) throws Exception {File file = new File("D01.mp4");startThread(30, file.length(), "D01.mp4","D:/s0s.mp4");}/*** 开启多线程复制* * @param threadnum*            线程数* @param fileLength*            文件大小(用于确认每个线程下载多少东西)* @param sourseFilePath*            源文件目录* @param targerFilePath*            目标文件目录*/public static void startThread(int threadnum, long fileLength, String sourseFilePath, String targerFilePath) {System.out.println("================");System.out.println(fileLength);long modLength = fileLength % threadnum;//求余后剩下的一些内存长度System.out.println("modLength:" + modLength);long targetLength = fileLength / threadnum;//每个线程要复制的长度System.out.println("targetLength:" + targetLength);for (int i = 0; i < threadnum; i++) {System.out.println((targetLength * i) + "-----" + (targetLength * (i + 1)));new FileWriteThread((targetLength * i), (targetLength * (i + 1)), sourseFilePath, targerFilePath).start();}if (modLength != 0) {System.out.println("最后的文件写入");System.out.println((targetLength * threadnum) + "-----" + (targetLength * threadnum + modLength));new FileWriteThread((targetLength * threadnum), targetLength * threadnum + modLength - 1, sourseFilePath,targerFilePath).start();}}/*** 写线程:指定文件开始位置、目标位置、源文件、目标文件,*/static class FileWriteThread extends Thread {private long begin;private long end;private RandomAccessFile soursefile;private RandomAccessFile targerFile;public FileWriteThread(long begin, long end, String sourseFilePath, String targerFilePath) {this.begin = begin;this.end = end;try {this.soursefile = new RandomAccessFile(sourseFilePath, "rw");this.targerFile = new RandomAccessFile(targerFilePath, "rw");} catch (FileNotFoundException e) {}}public void run() {try {soursefile.seek(begin);targerFile.seek(begin);int hasRead = 0;byte[] buffer = new byte[2048];while (begin < end && -1 != (hasRead = soursefile.read(buffer))) {// System.out.println("hasRead:"+hasRead);begin += hasRead;targerFile.write(buffer, 0, hasRead);}} catch (Exception e) {e.printStackTrace();} finally {try {soursefile.close();targerFile.close();} catch (Exception e) {}}}}
}
http://www.lbrq.cn/news/950347.html

相关文章:

  • 做外贸的物流网站/可以免费打开网站的软件
  • 农村建设集团有限公司网站/站长工具app下载
  • 淘客做的网站属于什么类型/北京网络营销推广外包
  • 学室内装潢设计哪个学校好/济南网站万词优化
  • 企业网站优化应该怎么做/杭州百度seo优化
  • 网站title keywords/长尾词挖掘工具
  • 专业做毕业设计网站设计/青岛模板建站
  • 高新区免费网站建设/时事政治2023最新热点事件
  • 高性价比网站建设/2345导航网址
  • 国内免费建站网站/杭州seo教程
  • 做网站骗/星巴克营销策划方案
  • 360网站安全检测/东莞网站建设推广
  • ps做电商网站流程图/百度网页排名怎么提升
  • 网站开发类型/百度上搜索关键词如何在首页
  • 企业网站开发制作/合肥360seo排名
  • 网站策划ps/百度网站搜索排名
  • 老网站改版做别的/百度收录入口
  • wordpress固定链接设置技巧/seo的实现方式
  • 上海网站关键词/百度网址大全下载
  • 程序开发平台哪个好/百度seo培训课程
  • 企业官网网站建设上海/开发网站建设
  • 单页网站如何制作/厦门关键词排名优化
  • 合肥手机网站建设/微信软文怎么写
  • java做web网站的流程/住房和城乡建设部
  • 微信上的网站/百度广告屏蔽
  • 网站建设科技公司/线下推广有哪几种渠道
  • 快速做网站用什么软件/长沙企业关键词优化
  • 重庆网站建设jwzcq/seo关键词快速排名前三位
  • 做网站怎么收费多少/今日新闻最新头条10条内容
  • 选择合肥网站建设/什么是网络营销的核心
  • 重构创作边界:川翔云电脑 - UE5云端超算引擎​
  • Linux中ELF区域与文件偏移量的关系
  • 感知机-梯度下降法
  • 音视频学习(四十二):H264帧间压缩技术
  • C# 结构体
  • Mysql(事务)