Commit b42b9fdd authored by ymwang's avatar ymwang

按照碎片数据量的大小排序

parent 792c1643
......@@ -219,7 +219,7 @@ public class FileService{
}
}
//给List集合里的元素进行排序
//给List集合里的元素进行排序,便于图片正常恢复
public List<FileSlice> sortList(List<FileSlice> list){
//List<FileSlice> list = new ArrayList<FileSlice>();
for (int i = 0; i < list.size(); i++) {
......@@ -237,6 +237,12 @@ public class FileService{
return list;
}
//对分割后得到的碎片List按照碎片的大小进行排序---使用冒泡排序
/* public SplitResult sortSpiltList(){
return null;
}*/
public void saveFile(String fileName, MergeResult mergeResult) {
BufferedImage images = mergeResult.getImages();
//输出拼接后的图像
......
......@@ -34,6 +34,20 @@ public class FileServiceImplement implements DistributedComService {
fileSlice.setFileBytes(byteList.get(i));//文件的比特数据
fileSliceList.add(fileSlice);
}
//对分割后的碎片,按照其数据量大小排序
for (int i = 0; i < fileSliceList.size()-1; i++) {
for (int j = 0; j < fileSliceList.size()-i-1; j++) {
if (fileSliceList.get(j).getFileBytes().length<fileSliceList.get(j+1).getFileBytes().length) {
/* int temp = fileSliceList.get(j).getSliceId();
nums[j] = nums[j+1];
nums[j+1] = temp;*/
fileSliceList.set(j,fileSliceList.get(j+1));
fileSliceList.set(j+1,fileSliceList.get(j));
}
}
}
SplitResult splitResult = new SplitResult();
splitResult.setFileSliceList(fileSliceList);
return splitResult;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment