• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Accessing TXT file on the server

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 AM MIGHTY! Especially when I hold this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic