Results 1 to 3 of 3
  1. #1
    Imoracle is offline Member
    Join Date
    Jan 2008
    Posts
    1
    Rep Power
    0

    Default Copy a .swf file from server side to client using signed applet

    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
    Java Code:
    坃ࡓ죃鱸뷤瀉�ᡚ穸s歒斷뛉쭬ⶲ뉯緤░뉋쭬틲��毳띵뺤畮祮୹釯烉쉍‼➀Ƿℵ㼤ꦅ㼌⡉⁈ș㖩䈼ꦓɊጵꨘ妆ၸ쇠鳳ﯯ龜괯䪅�쿾칿칷컹緶履殖㋿罣쯻杬�懨�E�翂䶙幷鿠︡拡ﬦ댨꾖政ᯋὣꯤ糥䧩缿䨗捫嶺깼瘶羋⯞勹쪾癞ঞ頁韧୘롻ⱖ撯貊攗閩㫙↳萰Ⳁ⼈쳂荡᧰ﻶ顠꓈鸎싔㿄㰧柂䪄러䂀좹㏠ꕊ㌏힟䘜㦴⌙⍈㽾ꙴ㿯렑㽔
    serverside.swf
    Java Code:
    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 :

    Java Code:
    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:

    Java Code:
     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

  2. #2
    Join Date
    Oct 2008
    Posts
    68
    Rep Power
    0

    Default

    I think this could be related to unicode ...as your file contains the non english characters....and this language characters seems to be multibyte...so try to use some stream which can writer multibyte stream.....writing plain bytes may be the issue

  3. #3
    Join Date
    Oct 2008
    Posts
    68
    Rep Power
    0

Similar Threads

  1. To transfer a file from client to server
    By phani in forum Networking
    Replies: 4
    Last Post: 10-12-2010, 06:15 PM
  2. send file via client - server model
    By spasavvas in forum Networking
    Replies: 15
    Last Post: 08-13-2010, 11:45 AM
  3. jsp program for client side printer to print these 2 strings on 3/3
    By for453 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 08-07-2007, 04:42 PM
  4. Replies: 0
    Last Post: 08-06-2007, 06:54 PM
  5. Replies: 6
    Last Post: 07-18-2007, 03:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •