File a=new File("D:/ceshi/2/2.txt");
FileOutputStream a1=new FileOutputStream(a);
InputStream b1=request.getInputStream();
byte v[]=new byte[20000];
int n;
while((n=b1.read(v))!=-1)
a1.write(v, 0, n);
a1.close();
b1.close();
String filename="t.txt";
byte cc[]=filename.getBytes("ISO-8859-1");
filename=new String(cc);
File c1=new File("D:/ceshi/2/"+filename);
RandomAccessFile randomwrite=new RandomAccessFile(c1,"rw");
RandomAccessFile randomread=new RandomAccessFile(a,"r");
int second=1;
String secondLine=null;
while(second<=2)
{
secondLine=randomread.readLine();
second++;
}
randomread.seek(0);
long four=0;
int four1=1;
while((n=randomread.readByte())!=-1&&(four1<=4))
{
if(n=='\n')
{
four=randomread.getFilePointer();
four1++;
}
}
randomread.seek(randomread.length());
long end=randomread.getFilePointer();
int j=1;
while( (end>=0) && (j<6))
{
end--;
randomread.seek(end);
n=randomread.readByte();
if(n=='\n')
{
end=randomread.getFilePointer();
j++;
}
randomread.seek(four);
while(four<end-1)
{
n=randomread.readByte();
randomwrite.write(n);
four=randomread.getFilePointer();
}
randomread.close();
randomwrite.close();
}
每次传完 文件后面都有一行多余的代码