Opening a text file from URL

Hello,

I know how to open image files using URLs. ImageIO.read(Class.class.getResource(string)); How I am supposed to open a text file using URL? I tried converting URL to string, which would fit the format for creating a file from string, but doesn’t seem to be working well. It is untill I export my project.

Ugh just found something on the internet.

http://weblogs.java.net/blog/kohsuke/archive/2007/04/how_to_convert.html

[quote=“trollwarrior1,post:1,topic:41406”]
Do you understand the difference between a URL, a String and a text file? I have no idea what you are trying to do. Some suggestions:

  • if you want to read the source indicated by the URL into a String (e.g. a webpage into a String), look here.
  • if you want to convert the URL to its String representation, simply do
String address = url.toString();

This is what you appear to be doing. The result is the URL address in plain text (e.g. “http://www.java-gaming.org”)