File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing TXT file on the server

 
ron Yairi
Greenhorn
Posts: 1
  • 0
  • 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
 
Bob Chad
Greenhorn
Posts: 19
  • 0
  • 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)
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic