Professional Documents
Culture Documents
JSPReadingTextFile
MOTOGPLAY,4TH
GEN(WHITE
APPLEIPHONE6S
(GOLD,64GB)
SHILPI
SHILPI
AAMAZING
(/index.html)
Home(/index.html)
Tutorials(/tutorials/)
Java(/tutorials/java/)
Jsp(/tutorials/java/jsp/)
JSPReadingTextFile
JSPReadingTextFile(/tutorials/java/jsp/readingTextFile.html)
Postedin:Java(/tutorials/java/corejava/index.html) Postedon:May16,2012at7:12PMComments:[0]
Like 0
Share
Tweet
Share
Advertisements
InthistutorialyouwilllearnabouthowtoreadtextfileinJSP.
JSPReadingTextFile
InthistutorialyouwilllearnabouthowtoreadtextfileinJSP.
InthisexamplewewilldiscussedabouthowtoreadtextfilefromtheJSPpage.ToreadthetextfilefromJSPpageIhavecreatedatextfilein
theWEBINFfolderandthencreatedaJSPpageintotheWebContentfolderontowhichstoredthefilepathintoaInputStreamclassusing
getResourceAsStream()methodofimplicitobjectapplication.TostorethecontentofafileusedtheBufferedReaderclassandtoreadthefile
contentsuseditsmethodreadLine()thatreadsthecontentsoffilelinebyline.
SHILPI
AILUN
ShilpiAamazingShilpi
Wirelesscharger,by
readingText.txt
Aman
Brijesh
Manish
Noor
Rajesh
Shashi
Vinay
Zayed
jspReadingTextFile.jsp
http://www.devmanuals.com/tutorials/java/jsp/readingTextFile.html
1/4
20/09/2016
JSPReadingTextFile
<%@pagelanguage="java"contentType="text/html;charset=ISO88591"
pageEncoding="ISO88591"import="java.io.*,java.net.*"%>
<!DOCTYPEhtmlPUBLIC"//W3C//DTDHTML4.01Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"
<html>
<head>
<metahttpequiv="ContentType"content="text/html;charset=ISO88591">
<title>JSPReadingTextFile</title>
</head>
<body>
<%
StringfileName="/WEBINF/readingText.txt";
InputStreamins=application.getResourceAsStream(fileName);
try
{
if(ins==null)
{
response.setStatus(response.SC_NOT_FOUND);
}
else
{
BufferedReaderbr=newBufferedReader((newInputStreamReader(ins)));
Stringdata;
while((data=br.readLine())!=null)
{
out.println(data+"<br>");
}
}
}
catch(IOExceptione)
{
out.println(e.getMessage());
}
%>
</body>
</html>
Output
WhenyouwillexecutetheaboveJSPpageyouwillgettheoutputasfollows:
DownloadSourceCode(/images/images1/1561jspReadingTextFile.rar)
OnePlus10000mAh
PowerBank
(Sandstone...
1,789
BuyNow
oneplus
GotoTopic Previous(/tutorials/java/jsp/index.html)
Home(/tutorials/java/jsp/index.html)
Next(/tutorials/java/jsp/index.html)
Tags:
http://www.devmanuals.com/tutorials/java/jsp/readingTextFile.html
2/4
20/09/2016
JSPReadingTextFile
RelatedArticles
HowtolearnAdvancedJavaProgramming?(/tutorials/java/HowtolearnAdvancedJavaProgramming.html)
JavaVideotutorial:HowtolearnJava?(/tutorials/videotutorials/howtolearnjava.html)
6ProgrammingLanguagesforLearnerstoBeginwithCoding(/tutorials/6ProgrammingLanguagesforLearners.html)
JavaVideotutorial:HowtocreatedirectoryinJava?(/tutorials/videotutorials/howtocreatedirectoryinJava.html)
VideoTutorial:HowtowritetoafileinJava?(/tutorials/videotutorials/howtowritetofile.html)
[0]Comments
REPLY
YourComment:
YourName(*):
YourEmail:
Subject(*):
YourComment(*):
SU B MIT
TutorialTopics
Java(/tutorials/java/index.html)
Devmanuals.com
661likes
LikePage
Share
Bethefirstofyourfriendstolikethis
http://www.devmanuals.com/tutorials/java/jsp/readingTextFile.html
3/4
20/09/2016
JSPReadingTextFile
Rs15,990
Rs8,499
Rs2,699
Rs1,449
Rs899
Rs1,299
Rs1,369
Rs1,499
Rs749
Rs1,299
Rs799
Rs2,290
Rs1,399
Rs18,490
Home(/index.html)
AboutUs(/aboutus.html)
PrivacyPolicy(/privacypolicy.html)
Copyrightdevmanuals.com2015.Allrightsreserved.
http://www.devmanuals.com/tutorials/java/jsp/readingTextFile.html
4/4