Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

Java Applet in HTML: FileInputStream not working in browser. Help please?

fileinputstream html browser stream

  • Please log in to reply
1 reply to this topic

#1 aisayli


    CC Lurker

  • Just Joined
  • Pip
  • 1 posts
  • Programming Language:C, Java, PHP
  • Learning:C, Java, PHP

Posted 18 October 2012 - 03:57 AM

Hello, recently I've created an applet in my IDE (jGrasp) using packages like "java.io.*" and apache. The applet takes an Excel file with data on it, puts it into a FileInputStream object, parses through the data using apache, and returns a window of values depending on what the user input.

On my IDE, it works great. The applet comes up, I receive the input window, input my information, and get back a certain set of values in another pop-up window (using then "swing" class). It works fine. FileInputStream works well.

But, when I put my applet into an HTML file- where the HTML file is in the same directory as the the .class file, the java package, the apache package, and the Excel file- the applet runs up to a certain point.
I get the input information window, I input my information, but when the code reaches the FileInputStream line, it just doesn't go on. I don't get any error messages. It just doesnt work. I am up to date with the java being run on the browser, so that's not it.

And I know it stops at the FileInputStream code because I have two checkpoint windows. One before that code is executed, and one after. The one before comes up, so up to there it works. But since the second doesn't come up, FileInputStream doesn't work for some reason. Oddly though, it will work on the IDE.

The applet is accessing my file system though. Everything is in the same folder. And the applet is accessing my file system when I run the applet from my IDE.
What I'm saying is that the applet is working. It's accessing exactly what it needs to. Up until its implemented into HTML. Now, does HTML not take files, even though they are in the same folder and directory. I can't see why it wouldn't.

Can anyone please help me understand why it will not work on HTML. I'll put a snippet of the code that I believe may be where the problem resides, hopefully someone can find the problem.

Help is greatly appreciated, thank you!


String filename ="AttendanceAreaByParcelDatabase.xls";

if(filename != null && !filename.equals(""))

//********FIRST CHECKPOINT********
JOptionPane.showConfirmDialog(null, "Works 1", "Test", JOptionPane.OK_CANCEL_OPTION);

FileInputStream fs =new FileInputStream(filename);

//*********SECOND CHECKPOINT**************
JOptionPane.showConfirmDialog(null, "Works 2", "Test", JOptionPane.OK_CANCEL_OPTION);

^^^^^^^^^^^^^^^^END OF CODE^^^^^^^^^^^^^^^^^^

~~Where it says "FileInputStream fs..." is where it stops working in HTML as seen by the checkpoints. If you understand the problem please help. Thank you!!~~
  • 0

#2 gregwarner


    Obi Wan of Programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1586 posts
  • Location:Arkansas
  • Programming Language:C, Java, C++, C#, PHP, Transact-SQL

Posted 18 October 2012 - 05:21 AM

Typically, the security settings in the user's browser disallow Java applets from performing any sort of local I/O, to prevent a malicious applet on a webpage from altering the user's hard drive. Check your browser's security settings.
  • 0

Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid

Also tagged with one or more of these keywords: fileinputstream html browser, stream

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download