blob: 88479e8496c50c2a32aad8c497bb16bd5ffae790 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
using System.Net;
using Mammoth.Couscous.java.io;
namespace Mammoth.Couscous.java.net {
internal class URL {
private readonly string _url;
internal URL(string url) {
_url = url;
}
internal InputStream openStream() {
try {
var response = WebRequest.Create(_url).GetResponse();
try {
return ToJava.StreamToInputStream(response.GetResponseStream());
} catch {
response.Close();
throw;
}
} catch (System.UriFormatException) {
return ToJava.StreamToInputStream(System.IO.File.OpenRead(_url));
} catch (System.Net.WebException exception) {
throw new java.io.IOException(exception.Message);
}
}
}
}
|