*******java后端实现******
package com;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
/**
* Created by ZBB on 2016/12/29.
*/
public class Zifu {
public static void main(String[] args){
String url="D:/test.js";
File file=new File(url);
if(!file.exists()||file.isDirectory()){
//System.out.print("不存在");
return;
}
StringBuffer sb=null;
BufferedReader br;
try{
br=new BufferedReader(new FileReader(file));
String temp=null;
sb=new StringBuffer();
temp=br.readLine();
while(temp!=null){
sb.append(temp+"\r");
temp=br.readLine();
}
}catch (Exception e){
e.printStackTrace();
}
String info=sb.toString();
info = info.replaceAll("\t","");
info = info.replaceAll(" ","");
info = info.replaceAll("\r","");
int number=info.length();
int LastNumber=number%10;
System.out.print("最后一位数为:"+LastNumber);
}
}
***********************JavaScript前端实现****************
function getJs(sUrl) {
var ie = navigator.userAgent.indexOf('MSIE') > 0;
var o = ie ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
o.open('get', sUrl, false);
o.send(null);
var ss=o.responseText;
ss=ss.replace(/\s/ig,'');
return { body : ss.length};
}
var a = getJs('include/test.js').body;
alert(a);
package com;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
/**
* Created by ZBB on 2016/12/29.
*/
public class Zifu {
public static void main(String[] args){
String url="D:/test.js";
File file=new File(url);
if(!file.exists()||file.isDirectory()){
//System.out.print("不存在");
return;
}
StringBuffer sb=null;
BufferedReader br;
try{
br=new BufferedReader(new FileReader(file));
String temp=null;
sb=new StringBuffer();
temp=br.readLine();
while(temp!=null){
sb.append(temp+"\r");
temp=br.readLine();
}
}catch (Exception e){
e.printStackTrace();
}
String info=sb.toString();
info = info.replaceAll("\t","");
info = info.replaceAll(" ","");
info = info.replaceAll("\r","");
int number=info.length();
int LastNumber=number%10;
System.out.print("最后一位数为:"+LastNumber);
}
}
***********************JavaScript前端实现****************
function getJs(sUrl) {
var ie = navigator.userAgent.indexOf('MSIE') > 0;
var o = ie ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
o.open('get', sUrl, false);
o.send(null);
var ss=o.responseText;
ss=ss.replace(/\s/ig,'');
return { body : ss.length};
}
var a = getJs('include/test.js').body;
alert(a);