Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
2
20230403
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
20230403
Commits
b7f3dc4b
Commit
b7f3dc4b
authored
May 26, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adres w pliku Ustawienia
parent
2ad5ee6e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
4 deletions
+9
-4
P01_Url.java
PC34-RestKlient/src/main/java/sklep/klient_rest/P01_Url.java
+1
-1
P02_Url_Json.java
...tKlient/src/main/java/sklep/klient_rest/P02_Url_Json.java
+1
-1
P03_HttpClient.java
...lient/src/main/java/sklep/klient_rest/P03_HttpClient.java
+1
-1
P04_HttpClient_Json.java
.../src/main/java/sklep/klient_rest/P04_HttpClient_Json.java
+1
-1
Ustawienia.java
...estKlient/src/main/java/sklep/klient_rest/Ustawienia.java
+5
-0
No files found.
PC34-RestKlient/src/main/java/sklep/klient_rest/P01_Url.java
View file @
b7f3dc4b
...
...
@@ -11,7 +11,7 @@ public class P01_Url {
public
static
void
main
(
String
[]
args
)
{
try
{
URL
url
=
new
URL
(
"http://localhost:8080/PC33-RestSerwer
/products.json"
);
URL
url
=
new
URL
(
Ustawienia
.
ADRES_USLUGI
+
"
/products.json"
);
try
(
InputStream
inputStream
=
url
.
openStream
())
{
Files
.
copy
(
inputStream
,
Paths
.
get
(
"wynik01.json"
),
StandardCopyOption
.
REPLACE_EXISTING
);
System
.
out
.
println
(
"OK"
);
...
...
PC34-RestKlient/src/main/java/sklep/klient_rest/P02_Url_Json.java
View file @
b7f3dc4b
...
...
@@ -13,7 +13,7 @@ public class P02_Url_Json {
public
static
void
main
(
String
[]
args
)
{
try
{
URL
url
=
new
URL
(
"http://localhost:8080/PC33-RestSerwer
/products.json"
);
URL
url
=
new
URL
(
Ustawienia
.
ADRES_USLUGI
+
"
/products.json"
);
try
(
InputStream
inputStream
=
url
.
openStream
();
JsonReader
reader
=
Json
.
createReader
(
inputStream
))
{
JsonArray
array
=
reader
.
readArray
();
...
...
PC34-RestKlient/src/main/java/sklep/klient_rest/P03_HttpClient.java
View file @
b7f3dc4b
...
...
@@ -13,7 +13,7 @@ public class P03_HttpClient {
public
static
void
main
(
String
[]
args
)
{
HttpClient
httpClient
=
HttpClient
.
newHttpClient
();
try
{
URI
uri
=
new
URI
(
"http://localhost:8080/PC33-RestSerwer
/products.json"
);
URI
uri
=
new
URI
(
Ustawienia
.
ADRES_USLUGI
+
"
/products.json"
);
HttpRequest
request
=
HttpRequest
.
newBuilder
(
uri
).
build
();
HttpResponse
<
String
>
response
=
httpClient
.
send
(
request
,
BodyHandlers
.
ofString
());
System
.
out
.
println
(
"response "
+
response
);
...
...
PC34-RestKlient/src/main/java/sklep/klient_rest/P04_HttpClient_Json.java
View file @
b7f3dc4b
...
...
@@ -19,7 +19,7 @@ public class P04_HttpClient_Json {
public
static
void
main
(
String
[]
args
)
{
try
{
JsonArray
array
=
pobierzJsona
(
"http://localhost:8080/PC33-RestSerwer
/products.json"
);
JsonArray
array
=
pobierzJsona
(
Ustawienia
.
ADRES_USLUGI
+
"
/products.json"
);
for
(
JsonValue
jsonValue
:
array
)
{
JsonObject
jsonObject
=
jsonValue
.
asJsonObject
();
System
.
out
.
println
(
jsonObject
.
getString
(
"productName"
));
...
...
PC34-RestKlient/src/main/java/sklep/klient_rest/Ustawienia.java
0 → 100644
View file @
b7f3dc4b
package
sklep
.
klient_rest
;
public
class
Ustawienia
{
public
static
final
String
ADRES_USLUGI
=
"http://localhost:8080/PC33-RestSerwer"
;
}
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