Update data documents for JWS deployed app - java

I have a swing application that uses many data files, these data files will change time to time. How can I load these data files on client's machine? Is there any way to create a folder like structure and run a batch file or so? Any help is appreciated.

There are several ways to do this:
Assume you want to ship your application with the datafiles, you may embed them as a zip/jar in your application-jar-file.
Extract the embedded zip to a temporary local file and use ZipFileSystemProvider to extract the content to some place on the disc.
Here is an example how to extract some content from zip/jar-file embedded in a .jar-file downloaded by JWS.
Same as 1, but skip the zip stuff and instead provide a list of all the resources you want to extract
One other way is to create the files pragmatically using either java.nio.file (java 7+) or java.io.File

Related

Upload JAR into database

Is it possible to upload jar as a file into database ? I need to upload jars into mongodb. I don't know how to do that. I know about file upload with Spring Boot.
I know it is possible to upload zip in database. But not finding information about JAR/WAR files.
JAR and WAR files are nothing more than a renamed ZIP file. If you want to see it yourself rename something.jar to something.zip and open it using archive manager.
Since you said you know how to upload a ZIP you should follow the same procedure. If the file is small (e.g. less than 4MB) perhaps using BSON is the best approach. See Storing Large Objects and Files in MongoDB.
If you mean saving a jar file into a database - it is depends on the database's support of BLOB data types.
And if you mean use Java language based stored procedures from JAR file - with Oracle and PostgreSQL this is possible. MongoDB supports server side JavaScript stored procedures only.

How can I add a file to another file which is such as named store.dat in Java?

All data must be stored in one single persistent file name secure_store.dat.
The following command should add new files to the Secure Store realm:
put [path_on_OS] [file_name]
How can I do this ?
How can I add a file that in my PC to secure.store ? Thank you.
If you don't mind that secure_store.dat will be a zipped file then you can use standard Java handling for zipped files...
Edit:
When you add multiple files together into one single file you must store them in such a way to preserve their boundaries, if you fail to do that the two or more files will become garbled mess.
java.util.zip functionality provides all features that you seem to need, it will create a zipped archive file with separate entries for each file that you add. It provides functionality to add/extract/remove files from the archive too.

How to open file for random access in libgdx

I need to open a file in libgdx for random access, i.e. I need to be able to seek() to different parts of the file (not read sequentially).
Using libgdx I am able to access the file via Gdx.files.internal(), but libgdx's filehandlers don't support random access methods like seek(). I tried using java.io.RandomAccessFile, but it generates the exception No such file or directory, probably because the file is stored internally in the jar file.
How can I access the file using java.io.RandomAccessFile` or alternatively how can i open file for random-access in libgdx?
This needs to work on both Android and desktop platforms.
This is not a Libgdx limitation. You cannot do random access on files stored inside a JAR file (since they're compressed, you need to stream the contents). (I can't find a concise reference for this, but look at the definitions of JarFile and ZipFile: they only let you create streaming file handles).
Libgdx itself runs into this problem. It stores native libraries in a .jar file (the libgdx-natives.jar). To use the files, it extracts them to the local filesystem and uses them from there. See SharedLibraryLoader.java.
As far as I can tell there are three workarounds to chose from:
Remove the need for the random access in your code.
Stream the file from the JAR into memory, and randomly access it there
Copy the file from the JAR into local (private) storage or temp storage (hopefully this could be done once and not re-done on each run of the app).

Android - How to package documents into an app

I'm trying to create an app and have the ability to save files to /data/data/(packagename)/files or a directory similar to that. The goal would be to have a pdf or doc handler, as necessary, open the files stored on the internal storage and be viewed by the user. I have the code to get a pdf reader that is installed and display the file but I do not know how to package the files so they are installed in a directory like the one above. Also, if I am able to do this would I use getResources to access the files? How should the file structure look in eclipse to make this happen on install of the APK?
I do prefer to have the files stored internally (they are small) and not on the SD card.
I admit I am new to this and am trying to learn as I go. Thanks for the help!
As I understand your approach you only need to place your files to assets folder of your application and then just copy them to the internal storage. Read more here.

Any Java plugin/code to manage uploaded files?

According to current requirement,user will upload files with large size,which he may like to download later. I cannot store the uploaded files in DB because the size of files is large and performance will be impacted if I store uploaded files in DB.
Any one knows any java plugin which provide efficient file management on webserver and maintains the link to file so that the file can be downloaded when the link is requested. Also the code will make sure that user will be able to download only those files which is uploaded by them,they cannot download any file just by modifying the download link etc. I am using spring3 as the framework.
Please suggest how to solve this problem?
if you have write access to the file system why not just save them there ?
you then generate an unique ID and save the hash/file relation in db, you then need to supply the ID to get the file feed from a servlet
Store the file content on a part of filesystem out of web application so you cannot reach it changing the link.
Then you can store on db the path for that file, and return them only if the user has the permissions to read it.
Pay attention, do not store all the file on the same folder, or the number of files could grow too much. So find a way to store them with more folder levels.

Categories

Resources