mirror of
				https://gitee.com/dromara/hutool.git
				synced 2025-10-31 16:36:56 +08:00 
			
		
		
		
	添加Stream进度条中总大小回调
This commit is contained in:
		| @@ -17,7 +17,7 @@ public interface StreamProgress { | |||||||
| 	 * | 	 * | ||||||
| 	 * @param progressSize 已经进行的大小 | 	 * @param progressSize 已经进行的大小 | ||||||
| 	 */ | 	 */ | ||||||
| 	void progress(long progressSize); | 	void progress(long contentLength, long progressSize); | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * 结束 | 	 * 结束 | ||||||
|   | |||||||
| @@ -107,7 +107,7 @@ public class ChannelCopier extends IoCopier<ReadableByteChannel, WritableByteCha | |||||||
| 			numToRead -= read; | 			numToRead -= read; | ||||||
| 			total += read; | 			total += read; | ||||||
| 			if (null != progress) { | 			if (null != progress) { | ||||||
| 				progress.progress(total); | 				progress.progress(this.count, total); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -108,7 +108,7 @@ public class ReaderWriterCopier extends IoCopier<Reader, Writer> { | |||||||
| 			numToRead -= read; | 			numToRead -= read; | ||||||
| 			total += read; | 			total += read; | ||||||
| 			if (null != progress) { | 			if (null != progress) { | ||||||
| 				progress.progress(total); | 				progress.progress(this.count, total); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -107,7 +107,7 @@ public class StreamCopier extends IoCopier<InputStream, OutputStream> { | |||||||
| 			numToRead -= read; | 			numToRead -= read; | ||||||
| 			total += read; | 			total += read; | ||||||
| 			if (null != progress) { | 			if (null != progress) { | ||||||
| 				progress.progress(total); | 				progress.progress(this.count, total); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -54,9 +54,9 @@ public class DownloadTest { | |||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			@Override | 			@Override | ||||||
| 			public void progress(long progressSize) { | 			public void progress(long contentLength, long progressSize) { | ||||||
| 				long speed = progressSize / (System.currentTimeMillis() - time) * 1000; | 				long speed = progressSize / (System.currentTimeMillis() - time) * 1000; | ||||||
| 				Console.log("已下载:{}, 速度:{}/s", FileUtil.readableFileSize(progressSize), FileUtil.readableFileSize(speed)); | 				Console.log("总大小:{}, 已下载:{}, 速度:{}/s", FileUtil.readableFileSize(contentLength), FileUtil.readableFileSize(progressSize), FileUtil.readableFileSize(speed)); | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			@Override | 			@Override | ||||||
| @@ -87,7 +87,7 @@ public class DownloadTest { | |||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 				@Override | 				@Override | ||||||
| 				public void progress(long progressSize) { | 				public void progress(long contentLength, long progressSize) { | ||||||
| 					System.out.println("download size:" + progressSize); | 					System.out.println("download size:" + progressSize); | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| @@ -121,8 +121,8 @@ public class DownloadTest { | |||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 				@Override | 				@Override | ||||||
| 				public void progress(long progressSize) { | 				public void progress(long contentLength, long progressSize) { | ||||||
| 					System.out.println("download size:" + progressSize); | 					System.out.println("contentLength:" + contentLength + "download size:" + progressSize); | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 				@Override | 				@Override | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 xufeng
					xufeng