摘要:
import java.io.*;
public class BufferedReaderWriter {
public static void main(String[] args) {
String content[] = {"好久不见了","最近好吗","常联系"};
File file = new File("E:/workspace/Java从入门到精通/mynote.txt");
try{
FileWriter fw = new FileWriter(file);
BufferedWriter bufferfw = new BufferedWriter(fw);
for(int k=0;kcontent.length;k++){
bufferfw.write(content[k]);
bufferfw.newLine();
}
bufferfw.close();
fw.close();
}catch(Exc 阅读全文
posted @ 2010-08-31 20:55
叮当小马
阅读(331)
评论(0)
推荐(0)
摘要:
import java.io.*;
public class FileInputOutputStream {
public static void main(String[] args) {
File file = new File("E:/workspace/Java从入门到精通/mynote.txt");
try
{
FileOutputStream out = new FileOutputStream(file);
String str = "程序设计离不开编程语言,但是编程语言在国内的大环境中似乎一直是个二等公民。国内的计算机教育和工程培训,似乎一直在宣传“语言不重要,重要的是思想”,“语言一通百通”等观点,甚至在许多人眼中“语言的讨论”完全是不入流的,但其实“编程语言”与“工具”、“框架”或是“开发方法”等事物一样,都对生产力有着重要的影响。事实上,语言的发展历史比其他方面更为悠久,并且在过去十几年,甚至最近几年中都依然在不断的碰撞,演变。期间一些新的语言诞生了,而另一些在当时看来阳春白雪的语言和编程范式也重新获得了人们的重视。";
阅读全文
posted @ 2010-08-31 20:52
叮当小马
阅读(276)
评论(0)
推荐(0)
摘要:
import java.io.*;
public class FileTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
File file = new File("E:/workspace/Java从入门到精通/mynote.txt");
if(file.exists())
{
file.delete();
System.out.println("文件已经删除。");
}
else
{
try{
file.createNewFile();
System.out.println("文件已经创建。");
}catch(Exception e)
{
e.printStackTrace();
}
}
}
} 阅读全文
posted @ 2010-08-31 20:49
叮当小马
阅读(259)
评论(0)
推荐(0)
摘要:
import java.util.*; //导入类
public class MapTest {
/**
* @param args
*/
public static void main(String[] args){
Map map = new HashMap();
Emp emp = new Emp("001","张三");
Emp emp2 = new Emp("005","张四"); //创建emp对象
Emp emp3 = new Emp("004","王一");
map.put(emp.getE_id(), emp.getE_name());
map.put(emp2.getE_id(), emp2.getE_name());
map.put(emp3.getE_id(), emp3.getE_name());
Set set = map.keySet();
Iterator it = set.iterator();
System.out.println( 阅读全文
posted @ 2010-08-31 20:42
叮当小马
阅读(313)
评论(0)
推荐(0)
摘要:
import java.util.*; //导入类
public class ListGather {
/**
* @param args
*/
public static void main(String[] args) {
List list = new ArrayList(); //集合类
list.add("a");
list.add("b");
list.add("c");
int i = (int)(Math.random()*(list.size()-1)); //0-2
System.out.println("随机获得数组中的元素:"+list.get(i));
for(int j =0;jlist.size();j++) //循环遍历集合
{
System.out.println(list.get(j));
}
}
} 阅读全文
posted @ 2010-08-31 20:39
叮当小马
阅读(244)
评论(0)
推荐(0)