MyEclipse------Quickly read the contents of a file in a specific directory

Source: Internet
Author: User

other.jsp

<%@ Page Language="Java"Import="java.util.*"pageencoding="UTF-8"%><%    StringPath=Request.getcontextpath (); StringBasePath=Request.getscheme ()+ "://"            +Request.getservername ()+ ":" +Request.getserverport ()+Path+ "/";%><%@page Import="java.io.*" %><!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"><HTML><Head><Basehref= "<%=basePath%>"><title>My JSP ' other.jsp ' starting page</title></Head><Body>    <%
file File=new file ("C://users//x550v//desktop", "Cc.txt");intN=-1; //defines the length of the byte array, and 100 indicates that you can use the a[0]~a[ About] bytea[]=New byte[Ten]; InputStream in=Newfileinputstream (file); //intRead ()//reads a single byte of data from the source of the output stream, with a return value of 0~255, if empty, returns-1 // while((n=in.read ())!=-1){ //here n can not be replaced with in.read (), if replaced, equivalent to the second call to the method, from 2,4, 6 double bytes start reading//out.print (n+"<br>"); //} //intRead (byteb[])//from the source of the input stream, in, reads a length of a.length bytes to the byte array A, returns the number of bytes actually read, or, if the end of the file, returns-1 //In.read (a); for(intI=0; I<A.length;i++){ //if the contents of Cc.txt are B, then A[i] is the ASCII code corresponding to B.//out.print (A[i]+"<br>"); //Out.print (a.length); } try{//intRead (byte[] B,intoff,int Len), returns the number of bytes actually read, or, if the end of the file, returns-1 //B: Byte array, off: Starts reading from the first byte in byte array B,Len: Indicates read every two bytes while((n=In.read (A,0, 2))!=-1){ Strings=New String(A,0, N); Out.print (S+"<br>"); } in.close (); } catch (IOException e) {out.print (e); } </Body></HTML>

MyEclipse------Quickly read the contents of a file in a specific directory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.