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()
{
readEvents()
readAnnouncements()
readQuotes()
}
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)
{
mq_text[mq_text.length]=strline;
}
}
//Close the input stream
DIS.close();
}
//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.