Skip to content
Advertisement

Tag: file

Tinylog Android, is it possible to clear the file?

I’m using the Tinylog library with the “rolling file” function to write logs to a file. Sometimes I need to clear a file. Tried to do it with normal Java methods but it breaks the file and makes it hard to read. Is there a way to clear the log file at any point so it doesn’t break? Answer You

Efficient way to get line number of bunch of string from a file

I want to search a list of strings from the file and get the line number. I am looking for an efficient way to do it. I don’t want to search one string at a time and open and close file. Answer Store the line numbers where each String appears in the file using a HashMap<String, List<Integer>>. This will allow

How can I output a random image when in a jar file?

The below code works when running from my editor but the image fails to load when compiled into a runnable jar file with eclipse. Could someone please suggest how I can modify my code or editor to load the files when compiled. I have read other methods of accessing files but since I need to select randomly from a folder,

Java – Method is not creating file text file

I got this method for creating a log file: but the file is not created, instead I get this error: Whats the fix for this? Answer Try putting the email.log directly as a child of the project root folder and a peer of src. project_root/src project_root/email.log (your file) This is probably happening because of the relative path usage on your

Cannot be resolved to absolute file path because it does not reside in the file system

My Code: I have already tried instead of .getFile(), extractJarFileFromURL or resource.getInputStream() but all this does not work. When I package my project and run it as a jar file and it tries to open the following file it always returns the following message. Error: java.io.FileNotFoundException: class path resource [assets/OPTIONS_DE. docx] cannot be resolved to absolute file path because it

Create directory without manage all files permission

How can i create directory in ( /storage/emulated/0/ ) without manage all files permission. This is my code : On android 11 its not working because it need manage all files permission. Answer From SDK 30 you can not access all file system without using MANAGE_EXTERNAL_STORAGE. If your app is in following categories you can ask for this permission: File

Advertisement