Results 1 to 4 of 4
- 10-01-2010, 12:24 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 2
- Rep Power
- 0
passing an entire file to a c++ function
Hello
I made a java application that is hosted in audio/midi sequencer Sonar through jVSTwrapper.
This application create a .zip file and then pass to the host in getChunk() function. My implementation is:
then, when requested, retrieves it from host and saves on disk with:Java Code:public int getChunk(byte[][] data, boolean isPreset) { int length = 0; data = new byte[1][1]; String fileName="filename.zip"; File zipFile=new File(fileName); FileInputStream fis=null; try { fis = new FileInputStream(zipFile); } catch (FileNotFoundException ex) { Logger.getLogger(myclass.getName()).log(Level.SEVERE, null, ex); } length=(int)zipFile.length();data[0]=new byte[length]; try { fis.read(data[0], 0, length); } catch (IOException ex) { Logger.getLogger(myclass.getName()).log(Level.SEVERE, null, ex); } length = data[0].length; try { fis.close(); } catch (IOException ex) { Logger.getLogger(myclass.getName()).log(Level.SEVERE, null, ex); } return length; }
The fact is that the restored file has the same size of the original one but I am not able to open it with winZip or winRar because I get an error like "damaged file or unknown format".Java Code:public int setChunk(byte[] data, int byteSize, boolean isPreset) { char[] arraychar=new char[byteSize]; int i; FileOutputStream outStream=null; File outf=new File("filename.zip"); try { outStream = new FileOutputStream(outf); } catch (FileNotFoundException ex) { Logger.getLogger(arpStylerVSTWrapper.class.getName()).log(Level.SEVERE, null, ex); } try { outStream.write(data,0,byteSize); } catch (IOException ex) { Logger.getLogger(arpStylerVSTWrapper.class.getName()).log(Level.SEVERE, null, ex); } try { outStream.close(); } catch (IOException ex) { Logger.getLogger(arpStylerVSTWrapper.class.getName()).log(Level.SEVERE, null, ex); } return 0;}
Thanks in advance for your help.
- 10-01-2010, 02:33 PM #2
For more information, do you have a compare program that can compare the two files?
You expect them to be byte for byte equal?
Or write a simple java program that reads bytes from each and prints out when the bytes are different.
- 10-01-2010, 03:39 PM #3
Member
- Join Date
- Oct 2010
- Posts
- 2
- Rep Power
- 0
the two file turn to be completely different, this is a sample:
right file
wrong fileJava Code:PK A= & C:\myfolder\myfile.asy풿j0w!ON,K,;J7C1 Eˡ#%n$Q(%}t2&E1" [oz&~l~j_0Lm3}X3ukiVf4ٳ1|uK!*+EDPJ0$4%Rf@DJ(dJeB * /`܍vS*+ FјTѵ^?SXx%~lgCo5}dӛPKC % ? PK A= C:\myfolder\m_s.asyKw#&x > L A""P"E%յ$Kt-Kr.,[Rj)I夻G=̜T1?5tSuk*Uu 8c}$g+}ӒkXdq\atb߉?ş5O~vwŷ4oMV$xS~poZĶ4zoG_>X- #V[G|u<z囒,yӈݛk_7E\Pg_I]_Xb.zu ;vH̘%~PkS4x<2ey Vm#,ox$ K/LXVD9\r-MI9yyΣ߿ϜG$au|Lrhu_Uxʊ
Java Code:B4 Oa B4 OP B4 O* B4 OT B4 O " B4 O $ B4 O & B4 O ( B4 O * B4 O , B4 O . B4 O4 0 B4 OPi 2 B4 O 4 B4 O 6 B4 O 8 B4 O : B4 O < B4 O B4 с[E^ ` - R 4!0 * HK j ` HK j HK t - HK Hq HK Hq h HK HK HK ȅ h. HK H HK HK HK H HK 1 HK H . HK H o HK HK ) HK H HK H v HK H Zk^ /0(0@0X0p00*000004 $0 \ <0
- 10-01-2010, 04:49 PM #4
Why do you think that binary data will make it thru the reads and writes that you are doing and stay unchanged. Are there other programs that read/write the data besides the two methods you show?
What does the "host" have to do with the transportation(reading/writing) of this data from the input zip file to the output file? Can the "host" have encoded/decoded the data?
Similar Threads
-
Passing an Array index into a function?
By dpedroia15 in forum New To JavaReplies: 3Last Post: 06-01-2010, 07:51 PM -
Example for passing string to a function.?
By mlibot in forum New To JavaReplies: 1Last Post: 03-19-2010, 06:36 AM -
[SOLVED] Making a new folder, reading an entire file in one block read
By fogus in forum New To JavaReplies: 15Last Post: 03-18-2009, 10:59 PM -
how use string array while passing to a function
By sks9s9 in forum New To JavaReplies: 2Last Post: 02-03-2009, 12:44 PM -
Passing a Vector object to a function
By evapisces in forum New To JavaReplies: 4Last Post: 09-27-2008, 03:18 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks