aspose file tools*
The moose likes Applets and the fly likes Accessing TXT file on the server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Accessing TXT file on the server" Watch "Accessing TXT file on the server" New topic
Author

Accessing TXT file on the server

ron Yairi
Greenhorn

Joined: May 03, 2011
Posts: 1
hi guys im new to this site so be kind
and im new to java applets as well

my problem is this:
im trying to access a txt file that is in the same directory as the Applet problem is it doesnt read the file
notice that with the exact URL im accessing my images and it does work, but the text file wont read

the code snippet is:

public void itemStateChanged(ItemEvent e) {

try {
Image sunday = getAppletContext().getImage(new URL(getCodeBase() + "sunday.gif"));
Image wednesday = getAppletContext().getImage(new URL(getCodeBase() + "wednesday.gif"));
Image thursday = getAppletContext().getImage(new URL(getCodeBase() + "thursday.gif"));
// URL url=new URL(getCodeBase().toString()+"info.txt");
URL url = new URL("ftp://username:passoword@schoolme.site90.com/public_html/Practice_page/info.txt");
BufferedReader br=new BufferedReader(new InputStreamReader(url.openStream()));

jLabel12.setText( br.readLine());

in this current form it works but it takes hours for the server to respond i want to access it with the // URL and it doesnt work
please help
thank you
Bob Chad
Greenhorn

Joined: May 20, 2010
Posts: 19
Hi,

Have you tried to access your Txt file directly in a web browser. If you cannot, it could be that the file server doesn't allow access to txt extension.
(defined in .htaccess)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing TXT file on the server