1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.configuration2;
19
20 import java.io.File;
21 import java.io.FileInputStream;
22 import java.io.FileOutputStream;
23 import java.io.IOException;
24 import java.io.InputStream;
25 import java.io.OutputStream;
26 import java.net.URL;
27 import java.net.URLConnection;
28 import java.net.URLStreamHandler;
29
30
31
32
33
34 public class FileURLStreamHandler extends URLStreamHandler {
35 @Override
36 protected URLConnection openConnection(final URL u) throws IOException {
37 final File file = new File(u.getFile());
38
39 return new URLConnection(u) {
40
41 @Override
42 public void connect() throws IOException {
43 }
44
45 @Override
46 public InputStream getInputStream() throws IOException {
47 return new FileInputStream(file);
48 }
49
50 @Override
51 public OutputStream getOutputStream() throws IOException {
52 return new FileOutputStream(file);
53 }
54 };
55 }
56 }