Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0b53a75

Browse files
committed
Improved format
1 parent0301ea9 commit0b53a75

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

‎src/main/java/generateimages/ImageDownloader.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313

1414
publicclassImageDownloader {
1515

16-
publicstaticvoiddownloadImage(StringimageUrl,StringdestinationFile)throwsIOException,InterruptedException {
16+
publicstaticvoiddownloadImage(StringimageUrl,StringdestinationFile)
17+
throwsIOException,InterruptedException {
1718
// Create an HttpClient
1819
HttpClientclient =HttpClient.newHttpClient();
1920

2021
// Create an HttpRequest for the image URL
21-
HttpRequestrequest =HttpRequest.newBuilder()
22-
.uri(URI.create(imageUrl))
23-
.build();
22+
HttpRequestrequest =HttpRequest.newBuilder().uri(URI.create(imageUrl)).build();
2423

2524
// Send the request and receive the response
26-
HttpResponse<InputStream>response =client.send(request,HttpResponse.BodyHandlers.ofInputStream());
25+
HttpResponse<InputStream>response =
26+
client.send(request,HttpResponse.BodyHandlers.ofInputStream());
2727

2828
// Get the InputStream from the response and write it to a file
2929
Pathpath =Paths.get(destinationFile);

‎src/main/java/generateimages/Main.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ public static void main(String[] args) throws IOException, InterruptedException
5252
intlasted =group ==null ? -1 :group.lastIndexOf('/');
5353
if (lasted >0 && !group.contains(":")) {
5454
StringfileName =group.substring(lasted +1).toLowerCase();
55-
if (fileName.endsWith(".png") ||fileName.endsWith(".jpg")
56-
||fileName.endsWith(".gif") ||fileName.endsWith(".svg")
57-
||matcher.group(1).contains("assets.")) {
55+
if (fileName.endsWith(".png")
56+
||fileName.endsWith(".jpg")
57+
||fileName.endsWith(".gif")
58+
||fileName.endsWith(".svg")
59+
||matcher.group(1).contains("assets.")) {
5860
if (!fileName.contains(".")) {
5961
fileName =fileName +".png";
6062
}
61-
if (!Files.exists(Path.of(file.getParent() +"/"
62-
+fileName))) {
63-
ImageDownloader.downloadImage(matcher.group(1),
64-
file.getParent() +"/"
65-
+fileName);
63+
if (!Files.exists(Path.of(file.getParent() +"/" +fileName))) {
64+
ImageDownloader.downloadImage(
65+
matcher.group(1),file.getParent() +"/" +fileName);
6666
matcher.appendReplacement(builder,fileName);
6767
}
6868
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp