Flask接口签名sign原理与实例代码浅析
296
2023-01-27
java实现两个文件的拼接
用java语言实现两个文件的拼接与上一篇用Java实现两个文件的异或使用的方法都一样,都是FileInputStream()与FileOutputStream()方法,两个相同大小的文件a,b,把文件b拼接在文件a之后,输出的文件名为outfile具体代码详见下述内容:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class Append
{
static int count=0;
static int countb=0;
public static void main(String args[]) throws IOException
{
FileInputStream filea = new FileInputStream("d:\\JavaXor\\a");
FileInputStream fileb = new FileInputStream("d:\\JavaXor\\b");
File outfile=new File("d:\\JavaXor\\outfile");
int filesizea=filea.available();//计算文件的大小
int filesizeb=fileb.available();
JCbRG FileOutputStream fos=new FileOutputStream(outfile);
int hasReada = 0;
int hasReadb=0;
byte[] bufa=new byte[1024];
byte[] bufc=new byte[1024];
byte[] buf_yua=new byte[filesizea%1024];
byte[] buf_yub=new byte[filesizeb%1024];
while( (hasReada=filea.read(bufa) )>0 )
{
if(count { for(int i=0;i { bufc[i]=(byte)(bufa[i] & 0xFF); count++; } fos.write(bufc); } else if(count>=filesizea-filesizea%1024 && count { for(int j=0; count>=filesizea-filesizea%1024 && count { buf_yua[j]=(byte)(bufa[j] & 0xFF); count++; } fos.write(buf_yua); } } while( (hasReadb=fileb.read(bufa) )>0 ) { if(countb { for(int i=0;i { http://bufc[i]=(byte)(bufa[i] & 0xFF); countb++; } fos.write(bufc); } else if(countb>=filesizeb-filesizeb%1024 && countb { for(int j=0; countb>=filesizeb-filesizeb%1024 && countb { buf_yub[j]=(byte)(bufa[j] & 0xFF); countb++; } fos.write(buf_yub); } } } }
{
for(int i=0;i { bufc[i]=(byte)(bufa[i] & 0xFF); count++; } fos.write(bufc); } else if(count>=filesizea-filesizea%1024 && count { for(int j=0; count>=filesizea-filesizea%1024 && count { buf_yua[j]=(byte)(bufa[j] & 0xFF); count++; } fos.write(buf_yua); } } while( (hasReadb=fileb.read(bufa) )>0 ) { if(countb { for(int i=0;i { http://bufc[i]=(byte)(bufa[i] & 0xFF); countb++; } fos.write(bufc); } else if(countb>=filesizeb-filesizeb%1024 && countb { for(int j=0; countb>=filesizeb-filesizeb%1024 && countb { buf_yub[j]=(byte)(bufa[j] & 0xFF); countb++; } fos.write(buf_yub); } } } }
{
bufc[i]=(byte)(bufa[i] & 0xFF);
count++;
}
fos.write(bufc);
}
else if(count>=filesizea-filesizea%1024 && count { for(int j=0; count>=filesizea-filesizea%1024 && count { buf_yua[j]=(byte)(bufa[j] & 0xFF); count++; } fos.write(buf_yua); } } while( (hasReadb=fileb.read(bufa) )>0 ) { if(countb { for(int i=0;i { http://bufc[i]=(byte)(bufa[i] & 0xFF); countb++; } fos.write(bufc); } else if(countb>=filesizeb-filesizeb%1024 && countb { for(int j=0; countb>=filesizeb-filesizeb%1024 && countb { buf_yub[j]=(byte)(bufa[j] & 0xFF); countb++; } fos.write(buf_yub); } } } }
{
for(int j=0; count>=filesizea-filesizea%1024 && count { buf_yua[j]=(byte)(bufa[j] & 0xFF); count++; } fos.write(buf_yua); } } while( (hasReadb=fileb.read(bufa) )>0 ) { if(countb { for(int i=0;i { http://bufc[i]=(byte)(bufa[i] & 0xFF); countb++; } fos.write(bufc); } else if(countb>=filesizeb-filesizeb%1024 && countb { for(int j=0; countb>=filesizeb-filesizeb%1024 && countb { buf_yub[j]=(byte)(bufa[j] & 0xFF); countb++; } fos.write(buf_yub); } } } }
{
buf_yua[j]=(byte)(bufa[j] & 0xFF);
count++;
}
fos.write(buf_yua);
}
}
while( (hasReadb=fileb.read(bufa) )>0 )
{
if(countb { for(int i=0;i { http://bufc[i]=(byte)(bufa[i] & 0xFF); countb++; } fos.write(bufc); } else if(countb>=filesizeb-filesizeb%1024 && countb { for(int j=0; countb>=filesizeb-filesizeb%1024 && countb { buf_yub[j]=(byte)(bufa[j] & 0xFF); countb++; } fos.write(buf_yub); } } } }
{
for(int i=0;i { http://bufc[i]=(byte)(bufa[i] & 0xFF); countb++; } fos.write(bufc); } else if(countb>=filesizeb-filesizeb%1024 && countb { for(int j=0; countb>=filesizeb-filesizeb%1024 && countb { buf_yub[j]=(byte)(bufa[j] & 0xFF); countb++; } fos.write(buf_yub); } } } }
{
http://bufc[i]=(byte)(bufa[i] & 0xFF);
countb++;
}
fos.write(bufc);
}
else if(countb>=filesizeb-filesizeb%1024 && countb { for(int j=0; countb>=filesizeb-filesizeb%1024 && countb { buf_yub[j]=(byte)(bufa[j] & 0xFF); countb++; } fos.write(buf_yub); } } } }
{
for(int j=0; countb>=filesizeb-filesizeb%1024 && countb { buf_yub[j]=(byte)(bufa[j] & 0xFF); countb++; } fos.write(buf_yub); } } } }
{
buf_yub[j]=(byte)(bufa[j] & 0xFF);
countb++;
}
fos.write(buf_yub);
}
}
}
}
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~