开发者

How to go about saving images to disk at runtime

开发者 https://www.devze.com 2022-12-20 11:41 出处:网络
I\'m creating a basic program (in Java) for a class that helps students study using flashcards, notes, etc.开发者_如何转开发I need a way to allow the user to upload a certain image or video into my pr

I'm creating a basic program (in Java) for a class that helps students study using flashcards, notes, etc. 开发者_如何转开发I need a way to allow the user to upload a certain image or video into my program so that it will be available even after they quit and relaunch.

I'm thinking of something along the lines of writeObject and readObject and creating "image" and "video" objects.

Can someone provide some advice about this? It would be much appreciated. I have very limited experience with GUI, so I'm having trouble getting started.


Using the swing framework, use JFileChooser to help you upload files (including video and images).

you can use Jimi for image io, and here's an example of a simple video player in java

Just create a folder somewhere and store the uploaded videos and videos there, then display and play them using an image or video framework like the ones above. Make that your default directory and just open it up each time your program loads up.


I find your problem description a little confusing... but if by "uploading" the image or video, you mean an existing file that your program would become aware of (since you are talking about GUI programming,), then you can use a FileChooser, and to save the file locations for next time the program is used you could use the Preferences API.

And concerning copying files from one location to another, see this SO thread which explains how to do it using the nio package or with the Apache Commons library.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号