My first Java post, as I am finally trying to learn a little Java, and am doing it the hard way, which is by trying to read other people's code, using Google, and the ww3 web site. It's not that difficult to learn what individual commands and all do, but it is difficult to get the context, the bigger picture.

Right now I am trying to do something that I'd think was very common, and that is reading a text file that is located on the server that host's the web site. I want to ready in each line so that I can display them are timed intervals.

I've seen lots of code examples but can't get any to work. I'm using Dreamweaver and I'd like to put this code in a template that all like page will use.

The code I am struggling with now is

<script language="javascript">
// import java.io.*;
var secs
var timerID = null
var timerRunning = false
var delay = 1000
var mq_text = new Array ();
var cc_text = new Array ();

function InitializePage()

function readQuotes()
	try	{
	// Open the file that is the first command line parameter
    FileInputStream FIS = new FileInputStream("data/quotes.txt");
    // Get the object of DataInputStream
   	DataInputStream DIS = new DataInputStream(FIS);
	BufferedReader BIS = new BufferedReader(new InputStreamReader(DIS));
	// The file will be read into this string variable.
    String strLine;
   	//Read the file line=by-line
    while ((strLine = BIS.readLine()) != null)   
		if (strLine.indexOf("*")=0) 
	//Close the input stream
	//Catch the exception, if any.
	catch (Exception e)
		System.err.println("Error: " + e.getMessage());

Dreamweaver says the line containing "FileInputStream" contains a syntax error. I suspected it needed the import line, but that also seems to generate an error because if I un-comment it none of my java code execute.

Thanks in advance for tutoring the naive beginner.

5 Years
Discussion Span
Last Post by masijade

This line here

<script language="javascript">

suggests to me that you might be in the wrong forum with this. javascript != java


Many thanks. Obviously the way I am going about learning this is going to get me stuck like this again.


Common enough mistake. Check out the Sun tutorials if you want to learn some Java - it's easier that way. For javascript, I don't know, I haven't really done any of that.


Are you trying to learn JavaScript, or Java, because judging by

I'd like to put this code in a template that all like page will use.

it looks like you really want JavaScript as Java has nothing to do with "pages". And please respond as if it is JavaScript you want I will move your post to the proper forum (not that this code will apply there, either, but at least you might get some good suggestions as to where to start).

Edited by masijade: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.