Note that there are some explanatory texts on larger screens.

plurals
  1. POtransferTo Java.nio fils with 00's when run through Matlab JVM?
    primarykey
    data
    text
    <p>Im using matlab jvm with Java.Nio to copy the body of a binary file to another file without the header.</p> <p>My code is:</p> <pre><code>fromfile = java.io.RandomAccessFile(ifile, 'rw'); fromchannel = fromfile.getChannel(); tofile = java.io.FileOutputStream(ofile); tochannel = tofile.getChannel(); tochannel.position(0); fromchannel.transferTo(n,fromfile.length()-n,tochannel); tochannel.close(); fromchannel.close(); fromfile.close(); tofile.close(); </code></pre> <p>and what i want is a hexidecimal start with 7F 7F (the start of my body after header) but what im getting is:</p> <pre><code>000004e0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 000004f0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000500h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000510h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000520h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000530h: 00 00 00 00 00 00 00 00 00 00 00 00 00 7F 7F 2F ; ............./ 00000540h: 07 00 07 14 00 4F 00 90 00 12 03 54 04 96 05 D8 ; .....O....T.–.Ø </code></pre> <p>Etc....Etc...</p> <p>Anyone know why its outputing like this?? I can't get it to write properly???</p> <p>EDIT 001.</p> <p>the matlab function im using is:</p> <pre><code>function TrimBinary(ifile,ofile,n) fromfile = java.io.RandomAccessFile(ifile, 'rw'); fromchannel = fromfile.getChannel(); tofile = java.io.FileOutputStream(ofile); tochannel = tofile.getChannel(); tochannel.position(0); fromchannel.transferTo(n,fromfile.length()-n,tochannel); tochannel.close(); fromchannel.close(); fromfile.close(); tofile.close(); end </code></pre> <p>My test input is:</p> <pre><code>00000000h: 05 FF 49 FF F4 FD 13 FF A5 FD A5 20 AC FD 55 FE ; .ÿIÿôý.ÿ¥ý¥ ¬ýUþ 00000010h: 67 FE C7 FF BE FD 75 FE CF FE 28 20 A1 FD 3F FE ; gþÇÿ¾ýuþÏþ( ¡ý?þ 00000020h: 1C FD 4B 20 D0 FD 49 FF 62 FF E7 FF 79 FD CF FE ; .ýK ÐýIÿbÿçÿyýÏþ 00000030h: 20 FD 31 FE 31 FE 46 FE C2 FC EF FE 52 FD F0 FD ; ý1þ1þFþÂüïþRýðý 00000040h: 40 FD 37 FF 2A FD A5 FD 2F FC EA FF FB FD 92 FE ; @ý7ÿ*ý¥ý/üêÿûý’þ 00000050h: 8C FC 20 80 20 80 83 FE 81 FD 3E FF 39 FD D3 FD ; Œü € €ƒþý&gt;ÿ9ýÓý 00000060h: F1 FC 5E FC 34 FE 79 FD 83 FB 7F 7F 99 FE 2A FD ; ñü^ü4þyýƒû™þ*ý 00000070h: 20 FD AF FD 7A FC 20 80 2A FD 35 FD 20 80 20 80 ; ý¯ýzü €*ý5ý € € 00000080h: F1 FC AA FB 20 80 20 80 FF FC 12 FC 20 80 20 80 ; ñüªû € €ÿü.ü € € 00000090h: 46 FE D1 FC 20 80 20 80 20 80 5D FD 01 FF 76 FD ; FþÑü € € €]ý.ÿvý 000000a0h: FB FD E6 FC 30 02 40 FD F4 FD A4 FE BA 01 20 80 ; ûýæü0.@ýôý¤þº. € 000000b0h: 46 FE 7B FF AB 01 57 FC BC FF 57 FF 6B 01 80 FE ; Fþ{ÿ«.Wü¼ÿWÿk.€þ 000000c0h: 61 20 3E FF 58 02 68 FD 62 FF 69 FF 4A 01 D3 FD ; a &gt;ÿX.hýbÿiÿJ.Óý 000000d0h: E1 FE 0C FF EA FF 55 FE 49 FF 51 FE EE FF 93 FD ; áþ.ÿêÿUþIÿQþîÿ“ý 000000e0h: F8 20 E2 FD 25 FF CD FC 05 FF 80 FE BE FD D8 FC ; ø âý%ÿÍü.ÿ€þ¾ýØü </code></pre> <p>My function Call:</p> <pre><code>TrimBinary('testin.000','testout.000',106) </code></pre> <p>My Output:</p> <pre><code>00000000h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000010h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000020h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000030h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000040h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000050h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000060h: 00 00 00 00 00 00 00 00 00 00 7F 7F 99 FE 2A FD ; ..........™þ*ý 00000070h: 20 FD AF FD 7A FC 20 80 2A FD 35 FD 20 80 20 80 ; ý¯ýzü €*ý5ý € € 00000080h: F1 FC AA FB 20 80 20 80 FF FC 12 FC 20 80 20 80 ; ñüªû € €ÿü.ü € € 00000090h: 46 FE D1 FC 20 80 20 80 20 80 5D FD 01 FF 76 FD ; FþÑü € € €]ý.ÿvý 000000a0h: FB FD E6 FC 30 02 40 FD F4 FD A4 FE BA 01 20 80 ; ûýæü0.@ýôý¤þº. € 000000b0h: 46 FE 7B FF AB 01 57 FC BC FF 57 FF 6B 01 80 FE ; Fþ{ÿ«.Wü¼ÿWÿk.€þ 000000c0h: 61 20 3E FF 58 02 68 FD 62 FF 69 FF 4A 01 D3 FD ; a &gt;ÿX.hýbÿiÿJ.Óý 000000d0h: E1 FE 0C FF EA FF 55 FE 49 FF 51 FE EE FF 93 FD ; áþ.ÿêÿUþIÿQþîÿ“ý 000000e0h: F8 20 E2 FD 25 FF CD FC 05 FF 80 FE BE FD D8 FC ; ø âý%ÿÍü.ÿ€þ¾ýØü </code></pre> <p>What I want is That the file Starts with "7F 7F", not "00 00"???</p> <p>Can anyone reproduce this problem? Find a Solution? Know what's going on???????</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload