on 12-17-2008 8:09 PM
I have found code sample for reading file inside webdynpro, but I can't manage to make it works with a text file on the web (ex.: "http:/.../file.txt").
Can someone post the exact code needed for that?
Thanks!
Have a look at class java.net.URL and method openStream().
http://java.sun.com/j2se/1.5.0/docs/api/java/net/URL.html
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hope this post will help people doing their homeworks...
StringBuffer tmpBuffer = new StringBuffer();
try {
URL url = new URL("http://.../test.txt");
URLConnection urlconnection = url.openConnection();
long l = urlconnection.getContentLength();
tmpBuffer.append("Content Length = " + l);
BufferedReader in =
new BufferedReader(new InputStreamReader(url.openStream()));
String line;
while ((line = in.readLine()) != null) {
tmpBuffer.append("\n" + line);
}
in.close();
} catch (Exception e) {
//System.out.println(e.toString());
}
if (tmpBuffer != null) {
wdContext.currentContextElement().setZoneMessage(
tmpBuffer.toString());
}
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.