Entry
how to call a html file in textarea
Apr 6th, 2008 18:52
ha mo, suresh kc, Colin Fraser, Sumegha,
<html>
<head>
<script language=Javascript>
function fileReader() {
//readFile is the name of the applet in the document
//getContents is the applet method that returns the contents of the file
//passed as the parameter to the applet via param tag
//see the applet code below
//you will have to compile the applet code first in order to
//be able to use this
var contents = document.readFile.getContents();
document.myform.txtarea.value = contents;
}
</script>
</head>
<body onload=fileReader();>
<applet name=readFile code=ReadFile.class width=1 height=1>
<param name=file value="ReadFile.java">
</applet>
<form name=myform>
<textarea name=txtarea cols=80 rows=20 NOWRAP>
</textarea>
</form>
</body>
</html>
//code for FileReader Applet
//FileName: ReadFile.java
import java.io.*;
import java.applet.*;
import java.awt.*;
public class ReadFile extends Applet {
String contents="";
public void init() {
try {
BufferedReader br = new BufferedReader
(new FileReader(getParameter("file")));
String s="";
while((s = br.readLine()) != null) {
contents += s+"\n";
}
br.close();
} catch (FileNotFoundException fnfe) {
contents = fnfe.getMessage();
}
catch(IOException ioe) {
contents = ioe.getMessage();
}
}
public String getContents () {
System.out.println(contents);
return contents;
}
}
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com