• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Accessing TXT file on the server

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
reply
    Bookmark Topic Watch Topic
  • New Topic