1700478090
接收者接口只是定义了每个接收者都必须完成zip和gzip相关的两个逻辑,有多少个职责就有多少个实现类。我们这里只有两个职责:压缩和解压缩,分别如代码清单32-15、32-16所示。
1700478091
1700478092
代码清单32-15 压缩接收者
1700478093
1700478094
public class CompressReceiver implements IReceiver{
1700478095
1700478096
//执行gzip压缩命令
1700478097
1700478098
public boolean gzipExec(String source,String to){
1700478099
1700478100
System.out.println(source+”—>”+to+“GZIP压缩成功!”);
1700478101
1700478102
return true;
1700478103
1700478104
}
1700478105
1700478106
//执行zip压缩命令
1700478107
1700478108
public boolean zipExec(String source,String to){
1700478109
1700478110
System.out.println(source+”—>”+to+“ZIP压缩成功!”);
1700478111
1700478112
return true;
1700478113
1700478114
}
1700478115
1700478116
}
1700478117
1700478118
代码清单32-16 解压缩接收者
1700478119
1700478120
public class UncompressReceiver implements IReceiver{
1700478121
1700478122
//执行gzip解压缩命令
1700478123
1700478124
public boolean gzipExec(String source,String to){
1700478125
1700478126
System.out.println(source+”—>”+to+“GZIP解压缩成功!”);
1700478127
1700478128
return true;
1700478129
1700478130
}
1700478131
1700478132
//执行zip解压缩命令
1700478133
1700478134
public boolean zipExec(String source,String to){
1700478135
1700478136
System.out.println(source+”—>”+to+“ZIP解压缩成功!”);
1700478137
1700478138
return true;
1700478139
[
上一页 ]
[ :1.70047809e+09 ]
[
下一页 ]