Hello to all Java Code Masters out thr,
I am trying to copy a .swf file from server side to client side, however I am unsuccessful in writing the correct data. By correct data I mean that , the data does gets saved on the client side in the .swf file, and the size of the .swf file on client side is as expected, but some how I don't know why the data is not the same as expected.
I tried opening up both the swf file, one which is on server side and the other which is on client side. And both looked different in the notepad.
When I opens up the client side .swf file on browser it shows nothing while the .swf file on server side worked fine.
Here is a snap shot of the two .swf files when opened in notepad:
clientside.swf
坃ࡓ죃鱸뷤瀉ᡚ穸s歒斷뛉쭬ⶲ뉯緤░뉋쭬틲毳띵뺤畮祮釯烉쉍‼➀Ƿℵ㼤ꦅ㼌⡉⁈ș㖩䈼ꦓɊጵꨘ妆ၸ쇠鳳ﯯ龜괯䪅쿾칿칷컹緶履殖㋿罣쯻杬懨E翂䶙幷鿠︡拡ﬦ댨꾖政ᯋὣꯤ糥䧩缿䨗捫嶺깼瘶羋⯞勹쪾癞ঞ頁韧롻ⱖ撯貊攗閩㫙↳萰Ⳁ⼈쳂荡᧰ﻶ顠鸎싔㿄㰧柂䪄러䂀좹㏠ꕊ㌏힟䘜㦴⌙⍈㽾ꙴ㿯렑㽔
serverside.swf
CWS x pZxzSRkeɶl˲-o}%Kl*]kununyypM< '5!$I
(H
5<B
J5Yx/*J߫w}
k2clga\%
serverside.swf is what I expect to be saved, but clientside.swf is what i get.
Below is a code snippet which I am trying :
public void writeswftoclient(String swfcontent) {
String userHome = System.getProperty("user.home" );
String ImoracleDirectory = userHome + "\\MyFolder";
File fdirectory = new File(ImoracleDirectory);
if(!fdirectory.isDirectory()) {
fdirectory.mkdir();
}
String playlist = ImoracleDirectory + "\\clientside.swf";
File fplaylist = new File(playlist);
try {
Writer output = null;
output = new BufferedWriter(new FileWriter(fplaylist,true));
*System.out.println(swfcontent);*
*output.write(swfcontent);*
output.close();
}
catch (Exception e) {
System.out.println("Cannot create or write to the playlist");
}
}
In above code I am trying to write the string swfcontent, which contains the data shown above in serverside.swf, to clientside.swf.
Interesting thing is that I am doing System.out.println(swfcontent); just before writing the data to clientside.swf using output.write(swfcontent);. And System.out.println does print the write data on the java console. However I dont know out of what reason the data doesnt get written correctly on the client's computer.
Kindly help me in this plzzzzzzzzzz.
PS: I tried saving a javascript file from server to client and it was saved successfully, with data as expected on the client side.
May be because the javascripts contained plain test like : document.write() while the .swf file contains raw binary data.
Kindly throw some light on it and help me get through this.
I even tried with the following manner:
public void writeswftoclient(String swfcontent) {
String userHome = System.getProperty("user.home" );
String ImoracleDirectory = userHome + "\\MyFolder";
File fdirectory = new File(ImoracleDirectory);
if(!fdirectory.isDirectory()) {
fdirectory.mkdir();
}
String playlist = ImoracleDirectory + "\\clientside.swf";
File fplaylist = new File(playlist);
try {
FileOutputStream out = new FileOutputStream(new File(playlist));
out.write(swfcontent.getBytes());
out.close();
}
catch (Exception e) {
System.out.println("Cannot create or write to the playlist");
}
}
but with no success.
One more thing I just noticed is that though the size of swf file on client side and server side seems to be same i.e. 33 Kb. But when I tried to see thr sizes in bytes by right click --> properties , The size of .swf file on client side is: 33200 while the size of .swf on server side is 33477.
Kindly help me