669 questions
-1 votes
1 answer
91 views
VS code: Java file that fetches api url throws a weird form of ClassNotFoundException
I am trying to create a program that fetches data from a url. When I try to debug it with VS code it outputs nothing. Even if I put "System.out.print("Something");" after the catch ...
0 votes
0 answers
58 views
HttpUrlConnection hangs out on POST request
I am working on custom gradle plugin which trigger API POST call. There is no many option for networking from gradle and UrlConnection looks as a best tool. I am able to trigger GET API call, but can ...
0 votes
0 answers
30 views
Unable to receive content from URLConnection client on ServerSocket host in Android
The following classes are running as threads, invoked from a fairly empty Android application (i.e., the app is really only being used to spawn the threads and then post a message to URLSender). The ...
0 votes
1 answer
750 views
No Suitable Driver Found using JDBC
So, I'm having the following issue: there is no suitable driver found for jdbc://C:/Users/Billy Bob Jones/Documents/My20Y1P2023.accdb . I am using spaces in my name. So, the error I am getting is: ...
1 vote
2 answers
835 views
can I send same HTTP request with same HttpURLConnection multiple times?
In order to send a string data to the server once, I do as below: Make “HttpURLConnection” to my URL address and open it Set the required headers for the connection I Set setDoOutput to True new a ...
0 votes
0 answers
42 views
Why conn.getResponseCode() throws an SSLHandShakeException "Received fatal alert: handshake_failure"?
I'm trying to get a JSON from moodle. My request is working from a browser bar and also with curl, but not from java. Here's a small piece of code that shows the issue. public static void main(String[]...
1 vote
1 answer
2k views
URLConnection.guessContentTypeFromName doesn't seem to work with csv extension
I have been using URLConnection.guessContentTypeFromName(String fname) to detect what mime type I need to use in my headers to return different documents. It was working fine until I tested with fname ...
0 votes
1 answer
2k views
Why Premature EOF Error has occur, while reading CSV file using SpringBoot Scheduled Task
Below shows the relevant code segments. Is it related to connection close or Buffer memory.? (The file, which contains 50MB+ AND 65000+ Text Lines) @Scheduled(cron = "0 0 9 * * *") public ...
-1 votes
1 answer
1k views
getContentLength() returning -1 but value expected was 127
What will be the output of the following Java program? import java.net.*; class networking { public static void main(String[] args) throws Exception { URL obj = ...
0 votes
0 answers
112 views
URLConnection - send parameter
How to add parameter to my object of type URLConnection? I have tried addRequestProperty("access_key,"dsd97sd863hb8323hjhd933ok4") and setRequestProperty("access_key,"...
1 vote
1 answer
409 views
Java URLConnection The cookie is not set
I am trying to develop an instagram scraper; this is my code: try { System.out.println("search in https://instagram.com/" + txtUsername.getText() + &...
0 votes
1 answer
76 views
Java Resolve Response URLConnection Header Value
I send http head request with URLConnection and got header value Content-Disposition Unreadable value like bellow. Content-Disposition: attachment; filename="৩টি ধাপে সহজেই...
1 vote
1 answer
293 views
URLConnectionReader produces UnknownHostException
Thanks in advance for every input! I'm getting a little familiar with how to read data from websites with Java and have tried to do this by reading data using a URLConnectionReader. Unfortunately I ...
0 votes
2 answers
1k views
Android - Error when downloading html sources: Trust anchor for certification path not found
I am downloading html source code of this webpage https://tv.zam.it/ch-Rai-1 using this: String content= ""; URLConnection connection = null; try { URL url = new URL(...
1 vote
1 answer
1k views
How to Mock URLConnection class using Mockito
I am trying to mock a method which is opening a connection using URLConnection class and then getting stream input. I want to mock the URLConnection class efficiently but am not able to do so. Below ...