View Single Post
  #1 (permalink)  
Old 08-05-2007, 05:26 PM
cachi cachi is offline
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.
Reply With Quote
Sponsored Links