1,777 questions
-3
votes
3
answers
212
views
Is the File class designed to be overridden? [closed]
I came across a class extending java.io.File. While this looked very peculiar to me, I couldn't find any documentation of whether the File class is meant to be overridden.
Note that the class is not ...
-2
votes
1
answer
140
views
Get real time file size in java
There is an existing api which writes the file to particular location and the code snippet is like below:
long lastUpdatedOn = System.currentTimeMillis();
try(...
0
votes
0
answers
59
views
Is it ok to suppress there warnings [duplicate]
I have code that has two warnings.
The code is from a commandline Expense manager project that uses a List to save and access expenses. Saving and retrieving the List is done via serialisation and ...
1
vote
1
answer
97
views
How do I write a multi line file with Writer?
I had success looping through my 5 database rows and writing a CSV file, except the code that I used rewrote the file every line. I will use the CSVParser to read the file to import an activity from ...
0
votes
0
answers
13
views
Beginner Java question on importing bufferedwriter in module-info.java
I am pretty new to java and I am trying to import some classes into my Java project, particularly java.sql and java.io.FileWriter + java.io.BufferedWriter
In my module-info.java, I have added the ...
1
vote
1
answer
63
views
Unable to read a file from a different method
I am a beginner in java and trying to solve the below use case.
Use case : From a file(input.txt) having numbers, find out and write all the unique numbers to a different file(output.txt) without ...
4
votes
1
answer
96
views
Do I need to flush an OutputStream before closing it?
There are a few related questions, but none of them quite provides the answer.
I provide a Serializer object, and it has a method setOutputStream() allowing the user to supply a destination for the ...
0
votes
1
answer
110
views
Native build issue with Java java.io.ObjectInputStream.readObject
Im trying to build my quarkus application in native mode using a dependency called EsperTech, and there is a specific snippet of code that after countless hours of debugging I discover that is causing ...
1
vote
1
answer
610
views
How to convert uploadedFile to file without giving path in struts2 spring
I need to use ActionUploadFileInterceptor. I implement UploadedFilesAware and need to convert UploadedFile to File. I write a method for convertUploadedFileToFile.
Is there any better way to convert ...
5
votes
0
answers
542
views
java.io VS java.nio when using Virtual Threads in Java 21
I am thoroughly learning Spring Boot and I am learning how to upload files and in my example I will be storing the path in the database and the contents in the file system outside of what is publicly ...
-2
votes
3
answers
154
views
How to merge multiple images into one in Java? [closed]
I have multiple images (.jpg/.jpeg/.png) in form of Spring's MultiPartFile. I need to transform them into a single MultiPartFile with images places vertically - preferably PDF, but other image formats ...
1
vote
2
answers
232
views
Java Program Cannot Locate CSV File in IntelliJ IDEA - FileNotFoundException [duplicate]
I’m working on a character recognition project using Java and IntelliJ IDEA. My program needs to load training and testing data from CSV files, but I’m encountering a FileNotFoundException even though ...
0
votes
0
answers
46
views
Scanner skipping .hasNextDouble() [duplicate]
I am trying to read several doubles from a file and save them in an array. The first number in the file is an integer, which should then determine the size of the array. This works. but when I try to ...
2
votes
1
answer
80
views
Password leak in MemoryDump from Java File which uses Java.io.Console
I got this code adapted from the official Java-Tutorial Page Console - Java Tutorial
public class RedirectOutputStreamExample {
public static void main(String[] args) throws InterruptedException {
...
0
votes
0
answers
53
views
Android Java bluetooth doesn't read all bytes
I need to send and read some bytes from Bluetooth, like serial port.
I use next code to connect device:
UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
...