Modify txt file at server - java

I am trying to make an app that can read, update, delete each line of a .txt file
How to access(read, update, delete) .txt file directly from the server with android device without having to download the .txt file.
This is the link I tried How to read from .txt file
but I got error when I tried it

You would have to make the changes serverside if you don't want to download the .txt file.
However, since a .txt file usually isn't that big, it should not be a problem to download it, edit it and upload it again using FTP.

Related

Why am I getting parsing error when opening APK file from app cache?

I'm trying to download an APK file online from within my app and then install it using Java. My code basically, downloads the file to the device from my server and then uses an Intent to open the installation message from the package manager and allow the app to be installed.
It works perfectly for me... unless I save the file to cache instead of regular storage. If I save it to cache instead, I get an error that it could not parse the APK file.
I checked and it is downloading the entire file to the cache correctly, but it just not installing. Any ideas?
The only difference in my code is that instead of using Environment.getExternalStorageDirectory() + "/file.apk" I'm trying to use context.getCacheDir() + "/file.apk" as for my file path.
I want to put the file in the cache so that Android can handle the cleaning of the file and so that I don't need to worry about handling write permissions on different Android versions and the variations of dealing with external storage.

HTML pages loading and showing them in .txt file

I'm trying to build a search engine in java where i have a folder "crawler" to store downloads but when I open my project and click on that file my computer gets stuck because it tries to load all the urls and texts parsed from the html pages (100k+) and tries to show them in .txt files in the "crawler" folder.
How can I prevent loading and showing them in the file ?
Store your data files somewhere outside of your project. Use e.g. a properties file to store the location to your crawler folder. You should only include such files in your project like source code. Something you would upload to Git or SVN. Not the data files your application operates on. If you would store this data in a database, you wouldn't include the whole database in your project, but only the SQL files to create the tables and views.

How to Download an mp3 into hidden folder

I am trying to download an mp3 file from an API into my mobile, I want it to download in a hidden folder.
I tryied the folder name start with "." (eg .foldername). But this file that I can access fom file manager, It only hidding form gallery and other apps.
Next I tried to Encrypt the dowloaded file. The problem that I face is, if the download is stop in the midway due some network issue, at that time what all packets (mp3) is downloaed that can acces in file manger,its not encrypting.
That is if downloading is stop when it is 50% , then the 50% of that file is access form the file manager, its only encrypting when the downloading is completing.
Also during file downloaing I can access the file from File Manager.
Is there any solution to hide the downloading file from the File Manager

Java Desktop opens files with different extensions

I am using Desktop class to open files like .txt files, .pdf files, images, etc; I have a problem that when I open first file, lets say a .jpg file, the images are displayed in the image viewer, then I try to open a .pdf document, the Desktop object tries to open the .pdf file with the image viewer, and it fails.
When I open the .pdf file first, it opens correctly. After that when I try to open a .jpg file, it is opened in the pdf browser. And so it fails...
In short, the first program associated with the first file, is used to open all the other files.
how can I solve it ?

How to download the zip file, Reads Zip archives with no intermediate disk/memory storage in servlet

I have one zip file (C:\source.zip ~130 mb size) common source in my server, I want to create new text file that depends on user info dynamically and append into that source.zip, then I need to give a download link to separate user.
My idea is, I will combine the source.zip and new user text file into one temporary folder (c:\temp). Then I will give the temporary folder as download link. After user downloaded the zip, I will delete the zip file in temp folder.
But my problem is, I will duplicate source into temp folder. So many users access this means server size will increase. So I want to read the (source.zip and text file) zip archives with no intermediate disk/memory storage to download in servlet.
How can I do this in servlet or jsp?

Categories