Skip to content

Commit 6b9fe1b

Browse files
committed
Use Path in response
1 parent e421aa8 commit 6b9fe1b

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/express/filter/FilterLayerHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class FilterLayerHandler {
2121

2222
public FilterLayerHandler(int layer) {
2323

24-
// Initialize layers
24+
// Create & initialize layers
2525
this.LAYER = new FilterLayer[layer];
2626
for (int i = 0; i < LAYER.length; i++)
2727
LAYER[i] = new FilterLayer<>();

src/express/http/request/Request.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77
import express.http.Cookie;
88
import express.utils.Utils;
99

10-
import java.io.*;
10+
import java.io.IOException;
11+
import java.io.InputStream;
12+
import java.io.OutputStream;
1113
import java.net.InetAddress;
1214
import java.net.InetSocketAddress;
1315
import java.net.URI;
16+
import java.nio.file.Files;
17+
import java.nio.file.Path;
1418
import java.util.HashMap;
1519
import java.util.List;
1620

@@ -102,10 +106,12 @@ public void pipe(OutputStream os, int bufferSize) throws IOException {
102106
* @param bufferSize Buffersize, eg. 4096.
103107
* @throws IOException If an IO-Error occurs.
104108
*/
105-
public void pipe(File f, int bufferSize) throws IOException {
106-
if (!f.exists() && !f.createNewFile())
109+
public void pipe(Path f, int bufferSize) throws IOException {
110+
if (Files.exists(f))
107111
return;
108-
pipe(new FileOutputStream(f), bufferSize);
112+
113+
Files.createFile(f);
114+
pipe(Files.newOutputStream(f), bufferSize);
109115
}
110116

111117
/**

0 commit comments

Comments
 (0)