Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-05-2007, 05:26 PM
Member
 
Join Date: Jul 2007
Posts: 40
cachi is on a distinguished road
Read a string from a txt file
Hi, I want to read a string from a txt file.
The program returns error at run time from the Java's security class.
Code:
try { FileInputStream fis = new FileInputStream("README.TXT"); int n; while ((n = fis.available()) > 0) { byte[] b = new byte[n]; int result = fis.read(b); if (result == -1) break; String s = new String(b); System.out.print(s); } // End while } // End try catch (IOException e) {System.err.println(e);} System.out.println();
Thanks.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-07-2007, 08:50 AM
Member
 
Join Date: Jul 2007
Posts: 35
silvia is on a distinguished road
Applet's don't have permission to read files from the client computer. You can either include the file in the jar of the applet, and then load the file using ClassLoader's getResource... methods. Or you can put the file on the same server as the jar, and then access it remotely (I'm not too familiar with J2SE but I think you create a Url object or something).
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to read a file directory willemjav Java Applets 2 04-17-2008 05:54 PM
How to read a text file from a Java Archive File Java Tip Java Tips 0 02-08-2008 10:13 AM
Read file tajinvillage Threads and Synchronization 0 01-29-2008 10:10 AM
read txt file sureshsri1981 JavaServer Pages (JSP) and JSTL 0 08-05-2007 04:49 PM
help to read .pst file through java umadas Advanced Java 0 07-30-2007 03:36 PM


All times are GMT +3. The time now is 07:49 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org