2013-11-25 3 views
0

RandomAccessFile transferFrom 함수를 사용하여 위치 1300 (uint8 개)에서 시작하여 fileto로 fileto 파일로 전송하려고합니다.Java transferFrom 바이너리 파일의 일부입니까?

fromfile = java.io.RandomAccessFile(ifile, 'rw'); 
fromchannel = fromfile.getChannel(); 
tofile = java.io.RandomAccessFile(ofile, 'rw'); 
tochannel = tofile.getChannel(); 
tochannel.transferFrom(fromchannel,n,fromfile.length()-n) 

tochannel.close(); 
fromchannel.close(); 
fromfile.close(); 
tofile.close(); 

출력 파일이 단지 비어 있습니다.

누구나 내가 잘못하고있는 것을 알고 있습니까 ??

편집 1 :

내가

fromchannel.transferTo(n,fromfile.length()-n,tochannel) 

tochannel.transferFrom(fromchannel,n,fromfile.length()-n) 

을 변경했습니다하지만 지금은 출력이 바로를 제외한 모든 파일을 인쇄하고 00 16 진을 많이두고 원본의 헤더는 어디에 ???

답변

1

당신은 내가 transferTo 위치에서 N

+0

확인 INFILE에 시작하면서, 위치에 n은 OUTFILE에서 시작

fromchannel.transferTo(n,fromfile.length()-n,tochannel) 

시도 transferFrom으로 생각 transferTo를 사용하려면, 나는 그래도 순서를 변경 fromchannel.transferTo (n, fromfile.length() - n, tochannel). 출력 파일이 삭제 된 헤더가 있던 시작 부분에 0을 많이 가지고 있다는 것을 제외하고는 그 작업은 ??? 어떤 아이디어 –

+0

처음에 0을 얻는 원인이 될지 모르겠습니다. java.io.FileOutputStream으로 전환하면 도움이 될 수 있습니다. – Scott

관련 문제