Issue
I need to create and open an HTML file at runtime.
<html>
<body>
<form name="Home" method="POST" action='' >
<input id='Title' type='hidden' value="Mr" name='Title'/>
<input id='Name' type='hidden' value="bala" name='Name'/>
.
.
.
</form>
<script language='javascript'>
//java script
</script>
</body>
</html>
In above format, i need to update value
field at runtime. After updating I want to open this html file within my android application.
Update: I know we can crate HTML file like below..
public static String createHTML(Study study) {
String format =
"<html>" +
"<body>" +
"<form name="Home" method="POST" action='' >" +
"<input id='Title' type='hidden' value='%d' name='Title'/>" +
.
.
.
.
" </body>" +
"</html>";
return String.format(format, study.title, study.name...);
}
but i wank to know is there any other way to create HTML file like creating XML file using XmlSerializer Thanks!
Solution
How to create html file.
- Open file
- Write text characters comprising the HTML
- Close file
If you need more details, the Oracle Java Tutorial has lessons on basic Java constructs, and on how to do simple file I/O.
There are other more "elegant" ways of doing this kind of thing in different contexts (e.g. in a web service) but if this the sum total of what you need to do, then ... keep it simple.
... is there any other way to create HTML file like creating XML file using XmlSerializer.
Not HTML. You could create XHTML that way through.
Having said that, constructing HTML or XHTML that way sounds like a poor idea. The resulting code would be neither readable or efficient ... compared with string concatenation or template-based approaches.
(Try it and see ...)
Answered By - Stephen C
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.