Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
sockets
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
DAI 26-27
sockets
Commits
92875883
Commit
92875883
authored
Sep 28, 2026
by
Miguel Reboiro-Jato
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reorders ESEIHomeDownload examples and fixes URL creation
parent
f2fe0ec0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
53 deletions
+54
-53
ESEIHomeDownload.java
.../es/uvigo/esei/dai/sockets/example5/ESEIHomeDownload.java
+19
-34
ESEIHomeDownload.java
.../es/uvigo/esei/dai/sockets/example6/ESEIHomeDownload.java
+35
-19
No files found.
src/main/java/es/uvigo/esei/dai/sockets/example5/ESEIHomeDownload.java
View file @
92875883
/*-
* #%L
* Ejemplos de DAI - Sockets
* %%
* Copyright (C) 2014 - 2026 Miguel Reboiro Jato
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
package
es
.
uvigo
.
esei
.
dai
.
sockets
.
example5
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.MalformedURLException
;
import
java.net.URI
;
import
java.net.http.HttpClient
;
import
java.net.http.HttpRequest
;
import
java.net.http.HttpResponse
;
import
java.net.URL
;
import
java.net.URLConnection
;
public
class
ESEIHomeDownload
{
public
static
void
main
(
String
[]
args
)
{
try
{
final
HttpClient
client
=
HttpClient
.
newHttpClient
();
final
URL
url
=
URI
.
create
(
"https://www.esei.uvigo.es"
).
toURL
();
final
HttpRequest
request
=
HttpRequest
.
newBuilder
()
.
uri
(
URI
.
create
(
"https://esei.uvigo.es"
))
.
GET
()
.
build
();
final
URLConnection
connection
=
url
.
openConnection
();
System
.
out
.
println
(
connection
.
getClass
());
final
HttpResponse
<
String
>
response
=
client
.
send
(
request
,
HttpResponse
.
BodyHandlers
.
ofString
());
System
.
out
.
println
(
response
.
body
());
}
catch
(
final
Exception
e
)
{
try
(
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
())))
{
String
line
;
while
((
line
=
br
.
readLine
())
!=
null
)
{
System
.
out
.
println
(
line
);
}
}
}
catch
(
final
MalformedURLException
e
)
{
e
.
printStackTrace
();
}
catch
(
final
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
src/main/java/es/uvigo/esei/dai/sockets/example6/ESEIHomeDownload.java
View file @
92875883
/*-
* #%L
* Ejemplos de DAI - Sockets
* %%
* Copyright (C) 2014 - 2026 Miguel Reboiro Jato
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
package
es
.
uvigo
.
esei
.
dai
.
sockets
.
example6
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.net.URI
;
import
java.net.http.HttpClient
;
import
java.net.http.HttpRequest
;
import
java.net.http.HttpResponse
;
public
class
ESEIHomeDownload
{
public
static
void
main
(
String
[]
args
)
{
try
{
final
URL
url
=
new
URL
(
"https://www.esei.uvigo.es"
);
final
HttpClient
client
=
HttpClient
.
newHttpClient
(
);
final
URLConnection
connection
=
url
.
openConnection
();
System
.
out
.
println
(
connection
.
getClass
());
final
HttpRequest
request
=
HttpRequest
.
newBuilder
()
.
uri
(
URI
.
create
(
"https://esei.uvigo.es"
))
.
GET
()
.
build
();
try
(
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
())))
{
String
line
;
while
((
line
=
br
.
readLine
())
!=
null
)
{
System
.
out
.
println
(
line
);
}
}
}
catch
(
final
MalformedURLException
e
)
{
e
.
printStackTrace
();
}
catch
(
final
IOException
e
)
{
final
HttpResponse
<
String
>
response
=
client
.
send
(
request
,
HttpResponse
.
BodyHandlers
.
ofString
());
System
.
out
.
println
(
response
.
body
());
}
catch
(
final
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment