JAVA读取文件,避免中文乱码。
1、JAVA读取文件,避免中文乱码。
/**
* 读取文件内容
*
* @param filePathAndName
* String 如 c:\\1.txt 绝对路径
* @return boolean
*/
public static String readFile(String filePathAndName) {
String fileContent = "";
try {
File f = new File(filePathAndName);
if(f.isFile()&&f.exists()){
InputStreamReader read = new InputStreamReader(new FileInputStream(f),"UTF-8");
BufferedRead
相关文档:
1.写一个方法,用一个for循环打印九九乘法表
/**
* 打印九九乘法口诀表
*/
public void nineNineMulitTable(){
for (int i = 1,j = 1; j <= 9; i++) {
System.out.print(i+"*"+j+"="+i*j+" ");
if(i==j){
i=0;
......
2009年9月出版的。同是《软件开发课堂》系列。本人在本书中编写的章节为:
第12章:多线程
第13章:IO流
第15章:反射
第16章:注解
第19章:网络编程
第20章:项目实例之网络版QQ
图书封面:
购买链接:http://www.china-pub.com/195979&ref=ps ......
java中时间戳和时间字符串之间的转换
获取当前的unix时间戳
new Date().getTime()
System.currentTimeMillis()
返回的是毫秒数,要转换long t = System.currentTimeMillis()/1000;
获取当前年月日以及时分秒
Calendar c = Calendar.getInstance();
c.get(Calendar.YEAR)) c.get(Calendar.YEAR)) c.get(C ......
JAVA里的PING是在JDK 1.5后用了新的函数isreachable去实现,具体介绍如下:
InetAddress对象的常用方法
InetAddress类有很多
get
方法,用来获取主机名,主机地址等信息。主要有:
byte[] getAddress() 返回次
InetAddress
对象的原始
IP
地址,保存为一个
byte
数组
String getCanonicalHostName() 获取此
I ......