java - SWT-App Loading .swf files from a runnable .jar or external folder -


I am programming in Java using SWT widget library in Eclipse, and I prepare a runable Java application I am doing I have received an application, I do not know how to load external .swf files from a folder on "ALL" computer. I can load images from any computer, because I use the getResourceAsstream line of code. But "import com.docuverse.swt.flash.FlashPlayer" "loadMovie (arg, arg)" takes only one string.

So I did classname.clash .getResource ("blah.swf"). GetPath (); Which gives you a string, I set it up, and it can get the package completely in the file running on eclipse. When I export it, then I can not find ".blah.swf" inside the .jar file, which I created a runner-up jar.

So my problem is, how do I load from my SSF files? Jar or any external folder, so customers can download with .jar executable application, so it can point to those SDF files.

Thankyou.

The way I was talking about the comment (creating temporary files and flash animation from jars To save)

  import java io.File; Import java.io.FileOutputStream; Import java.io.IOException; Import java.io.InputStream; Import org.eclipse.swt.SWT; Import org.eclipse.swt.layout.FillLayout; Import org.eclipse.swt.widgets.Display; Import org.eclipse.swt.widgets.Shell; Import com.docuverse.swt.flash.FlashPlayer; Public category SWTFlashPlayer {Private Flash Player Player = empty; Private end string FLASH_FILE_PATH = "/EdnCateDance.swf"; Private end string TMP_FILE_PREFFIX = "tmp_"; Private last string TMP_FILE_SUFFIX = ".swf"; Private file swfFile = null; Public SWTFlashPlayer () {Final Display Performance = New Performance (); Last Shell Shell = New Shell (Display); Shell.setLayout (new FillLayout ()); Try {SwfFile = copyFileFromJar (FLASH_FILE_PATH, TMP_FILE_PREFFIX, TMP_FILE_SUFFIX); } Hold (IOException e) {e.printStackTrace (); Return; } Player = New Flash Player (Shell, SWT.NONE); Player.loadMovie (0, swfFile.getAbsolutePath ()); Player Size (150, 150) Size; Player.activate (); Shell.pack (); Shell.open (); While (! Shell.isDisposed ()) {if (! Display.readAndDispatch ()) display.sleep (); } Display.dispose (); } / ** * Copy file copied to temporary file inside current jar * @ Ultimate Jarpath String - Path inside jar * @PRF filefix string - Temporary file prefix * @x filefix - Temp file suffix * @ throw IOException - temp File can not be created or written some way * / Private file copyFileFromJar (string jarpath, string filefix, string filefixes) throws IOException {file toFile = File.createTempFile (FilePreffix, fileSuffix); // Delete the file after application is finished. Feel.DietOnAixit (); If (ToFile.canWrite () to throw new IOException ("file (" + toFile.getPath (+++ ") does not exist or is not writable!"); FileOutputStream fos = New FileOutputStream (toFile); InputStream = This.getClass (). GetResourceAsStream (jarPath); if throwing new IOException ("File can not be located on the JAR path or loaded!"); Int read = 0; Byte Bites [] = New byte [1024]; while ((read = is.read (bytes))! = -1) {fos.write (bytes, 0, reading);} Fos.flush (); fos.close (); Return to;} Public static zero main (string [] args) {new SWTFlashPlayer ();}}   

I used the addicate.swf flash file which is one of the examples in the SWT Flash Library.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -