Java的IO实例
//Java的IO的一个实例
import java.io.*;
import java.util.zip.*;
public class abc5{
String temp=new String();
String t=new String();
public void readByLinefromConsoleAndPrint(){
System.out.println("==从控制台获得输入==");
try{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.println("请输入一行字符:");
System.out.println(temp=in.readLine());
}
catch(IOException e){
e.printStackTrace();
}
}
public void readByLinefromFileAndPrint(){
System.out.println("==从文件获得输入==");
try{
BufferedReader in=new BufferedReader(new FileReader("abc.dat"));
temp="";
String s=new String();
while((s=in.readLine())!=null)
temp+=s+"\n";
in.close();
System.out.println(temp);
}
catch(FileNotFoundException e){
e.printStackTrace();
}
catch(IOException e){
e.printStackTrace();
}
}
public void readfromMemoryAndPrint(){
System.out.println("==从内存获得输入==");
try{
StringReader stringReader=new StringReader(temp);
int t;
while((t=stringReader.read())!=-1)
System.out.println((char)t);
}
catch(IOException e){
e.printStackTrace();
}
}
public void writeToFile()
{
System.out.println("==文件输出流==");
try{
BufferedReader in=new BufferedReader(new StringReader(temp));
PrintWriter out=new PrintWriter(new BufferedWriter(new FileWriter("abc.dat")));
while((t=in.readLine())!=null)
o
相关文档:
今天终于把JAVA里一个比较头痛的问题——字符编码弄清晰了,所以写一篇文章来纪念一下,也为大家提供一点自己的心得。
众所周知,JAVA为了国际通用,用的是UNICODE来保存里面的字符。而UNICODE只是一个种字符集,字符的存储和表示要用到一定的字符编码格式,而与UNICODE对应的字符编码格式就是我们常看到的U ......
主要的程序:
package greeds.jdbc.sample;
import greeds.jdbc.util.JDBCUtil;
import java.io.*;
import java.sql.*;
public class MySQLBlobSample {
public static void main(String[] args) throws Exception {
// 写入数据库
/*
*
* Connection ......
这是一次培训总结,是我在学习的过程中记录下来的,非常完整,我感觉适合初学者学生可能更需要所以发表 ,请多给与评价-------
---------WangMX
《Java Web程序设计基础教程》第1章)
1 JSP 和 Java的关系
一般Java指的标注版 Java SE
另外两个版本:Java EE 和 Java ME
  ......
主要是利用Java提供的util包中的Properties类。废话不多说,直接看代码:
view plaincopy to clipboardprint?
import java.util.*;
public class YourJavaProperties {
public static void main(String args[]){
Properties props=System.getProperties();
System.out.println("Java的运行环境版本:"+props.getP ......
在开始这个计划前,我想还是想和大家分享一下我对未来Java之路的憧憬,虽然Java的母公司Sun在经受着Oracle公司收购,导致着整个Java阵营的一阵异议,但是最新的JavaEE 1.6的标准的制定,还是可以看出Java现在仍然充满着生命力,至少在最近5年还是会保持他强大的生命力。 ......