Download a file with its given name
Normally if you want to download a file through your browser, the browser asks you for the destination path and the name of the file is already given.
Now I want to download a file with that specific filename. How can I do that?...
GETTERS AND SETTERS
I'm having trouble understanding how getters and setters work. can anyone help explain them to me in like a summarized format. Thanks!
My tests are being ignored in IntelliJ.
Hey, I'm trying ouy Java with spring boot. I have a simple guess the word game, with the word being a cocktail that is retreived with an API. User inputs their guess, and dpeending whether or not they are correct they can try again or quit. I wanted to write some tests and ran into a problem that my tests have the ignored status for whatever reason. The below code for example should test for the getcocktail method being called once for example. Tried googling but little info on the issue.
```
import com.google.gson.JsonObject;
import com.ridango.game.ApiService;...
Asyncronous task queue
I have one thread that delegates tasks over to another thread, which runs those tasks in a queue. These tasks are blocking tasks (database), that I want to be run in the correct order, first in first out.
Currently using BlockingQueue, but when testing it using junit, it can freeze the whole test. That's because after each test, this thread is waited on until it finishes. I have not found a good way to enable/disable the queue
How would one do this properly?...
prepping for an exam, new to java & might need help understanding some stuff
im just gonna put in questions here as I study
ill probably not ask a whole ass program explanation unless its fully indecipherable to me
ill bold whatever is the tldr version if you dont want extra context...
system doesn´t end once I enter -1 in the console how can I change that
`´import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
...
Need help fast pls (minecraft code)
java.lang.NullPointerException: Cannot invoke "im.furious.utils.drag.Dragging.getX()" because "this.dragging" is null
This error does not allow drawing hood elements.
ds: 196devblog...
[Spring] Should I have a custom Objectmapper as a static attribute in my service class?
Currently have an Objectmapper, from the JSON jackson serialization api, from my configuration class used in my Service class. Using lombok, realized the @AllArgsConstructor doesn't create a constructor for static attributes.
It makes sense to have it be static in the conventional sense, since it should be shared between service instances.
It is making it hard to do unit tests. As best practice, should I be having the objectmapper attribute in my service class be static or not?
I'm thinking I can forgo making it static since I'm getting a universal Objectmapper from the spring context anyway....
Gradle & Java Version
Im searching for the correct garde & java version to run thsi repo: https://github.com/boazy/TWEditorEnhanced
currently i tried
gradel v8: java 20
7:java20
6.22 java20...
scanner blocking thread close
in a project im working on i have a client with a sender and receiver thread. When the server send the quit command im also sending the clients the "quit" message which should intterupt their sender and receiver threads. The receiver ends just fine but the sender (that has the scanner) is stuck waiting for the next line. What's the appropriate way to handle this? i tried closing the senders' scanner in the receiver among other things but nothing worked
PMD Java source analyzer insights in code insights section
Hi
I was trying to see if it's possible to use pmd and display the error as a highlight like intellij ones .
I found for vs code...
i need help for my code
Hi everyone i need help for this code my teacher want to do a pyramid with star in java with while and if not whit for ! can someone help me to result my problems
Java Hibernate with Negative Enums
I'm using Hibernate for JPA for persisting objects to my database. One class has four possible statuses that I want to represent with an enum, and I want to use a negative status for DELETED for consistency with previous classes:
```
public enum Status {
PENDING (0)
APPROVED(1)...
Beginner to Java - Help
Hi! This is not a question concerning one line of code, so if there’s a more suitable place for this please redirect me. I would also like to state that I’m a beginner at Java!
I have started my first project being a text adventure game in Java and I am wondering if someone more experienced could be kind and let me sit down and talk over it? I’m hoping to learn from it, get some input on how I can improve structure and format classes, something I find a little confusing. It would mean a lot! Thanks 😄
Feel free to dm me or @ me!!...
Problems with dates
Anyone can help me? i want this patterns in my LocalDate but always get a exception
Public class error
Hello! This is probably a stupid question, but I am trying to follow a tutorial on unit-testing but am getting an error on my public class. I do not understand what is wrong, as the class name is matching the file name- please help me out!
Thank you. I'm a beginner!...