eclipse 中的每樣?xùn)|西都是插件, 所以可以通過(guò)添加插件實(shí)現(xiàn)強(qiáng)大的功能, 并且可以支持更多語(yǔ)言的開(kāi)發(fā), 入C,C++,PHP等.
eclipse 分支 = eclipse標(biāo)準(zhǔn)版 + 相關(guān)功能插件集
java平臺(tái)的劃分
1, Java SE --Java平臺(tái)標(biāo)準(zhǔn)版 : 提供了java平臺(tái)開(kāi)發(fā)的標(biāo)準(zhǔn)類庫(kù)
2, Java EE -- Java平臺(tái)企業(yè)版: 在SE基礎(chǔ)上,增加了網(wǎng)站開(kāi)發(fā)的類庫(kù)
3, Java ME -- Java平臺(tái)微型版: 主要用于手機(jī), ppa等移動(dòng)平臺(tái)的開(kāi)發(fā)
java語(yǔ)言特征
1, 語(yǔ)法簡(jiǎn)明, 2,面向?qū)ο? 3 跨平臺(tái)(可移植性強(qiáng)),4 安全, 5,多線程
java語(yǔ)言運(yùn)行機(jī)制
1, 編譯與解釋結(jié)合的語(yǔ)言
2, .java: 可直接閱讀的源程序
3, .class: 不可直接閱讀的字節(jié)碼
4, Java解釋器不跨平臺(tái), .java和.class跨平臺(tái)
補(bǔ)充: "java解釋器就是把在java虛擬機(jī)上運(yùn)行的目標(biāo)代碼(字節(jié)碼)解釋成為具體平臺(tái)的機(jī)器碼的程序。"即jdk或jre目錄下bin目錄中的java.exe文件,而javac.exe是編譯器。
運(yùn)行java程序的過(guò)程是先用javac編譯,然后用java解釋。而一經(jīng)編譯成功后,就可以直接用java.exe隨處解釋運(yùn)行了
JDK
java標(biāo)準(zhǔn)版開(kāi)發(fā)包, 是一套專門(mén)用于java開(kāi)發(fā)的工具包, JDK提供了編譯,運(yùn)行,調(diào)試java程序所需的工具.
JRE
JRE是Java運(yùn)行時(shí)環(huán)境. 是運(yùn)行java程序必須的條件
JVM?
JVM是Java虛擬機(jī)
JDK ?JRE ?JVM 關(guān)系圖

JAVA API
是Java系統(tǒng)核心類庫(kù)
JAR
是java的歸檔文件, 是與平臺(tái)無(wú)關(guān)的文件格式, 它允許將許多文件組合成一個(gè)壓縮文件
環(huán)境變量
環(huán)境變量是一個(gè)具有特定名字的對(duì)象, 它包含了一個(gè)或者多個(gè)應(yīng)用程序?qū)⑹褂玫降男畔?/p>
文件的創(chuàng)建, 刪除, 重命名 ?
File file = new File("hello.txt");? //hello.txt為文件名
//寫(xiě)不同的目錄,就創(chuàng)建在了不同的目錄下 可以寫(xiě)文"bin/hello.txt","../hello.txt", '../../hello.txt' ?
../表示文件被創(chuàng)建在了工程的上一級(jí)目錄, ../../表示上一級(jí)的上一級(jí)目錄
//是否存在
if(file.exists()){
//判斷文件的屬性 是文件還是路徑
? //文件, 存在為true, 不存在為false
? ?System.out.println(file.isFile());
//路徑(文件夾)
System.out.println(file.isDirectory());
} else {
System.out.println("文件不存在");
}
創(chuàng)建:
如果文件不存在, 則去創(chuàng)建文件
創(chuàng)建文件的代碼: ?file.createNewFile(); ?
加上異常判斷?
try {
file.createNewFile();
System.out.println("文件已經(jīng)被創(chuàng)建");
} catch (IOException e) {
//出現(xiàn)異常, 則輸出,文件無(wú)法被創(chuàng)建
System.out.println("文件無(wú)法被創(chuàng)建");
}}
刪除:
file.delete();
重命名:?
//文件的重命名
//創(chuàng)建一個(gè)新的文件
File nameto = new File("new Hello.txt");
//調(diào)用文件的重命名方法
file.renameTo(nameto);
這時(shí)候文件名變成為了 new Hello
文件夾的創(chuàng)建,重命名, 刪除
創(chuàng)建:
File folder = new File("my new folder");
folder.mkdir():創(chuàng)建文件夾
mkdir 返回值為bool類型, 如果為真則為true, 為假則為false
所以可以通過(guò)if判斷來(lái)判斷文件夾是否創(chuàng)建成功
if(folder.mkdir())
{
System.out.println("文件夾創(chuàng)建完成");
} else {
//文件夾如果已經(jīng)存在, 則是不能創(chuàng)建的
if (folder.exists()){
System.out.println("文件夾已經(jīng)存在不用創(chuàng)建");
} else {
//要?jiǎng)?chuàng)建的文件夾的上級(jí)文件夾必須存在, 如果上級(jí)文件夾不存在, 則會(huì)調(diào)用這個(gè)地方
System.out.println("文件夾創(chuàng)建失敗");
}
}
// 用 madirs() 創(chuàng)建文件夾, 就不會(huì)有上面文件夾創(chuàng)建失敗原因的局限, 不管中間缺失了多少級(jí)文件目錄結(jié)構(gòu), 都會(huì)自動(dòng)補(bǔ)全
File folder = new File("my new folder/one/two/three");
if(folder.mkdirs())
{System.out.println("文件夾創(chuàng)建完成");}
重命名:
//文件夾的重命名, 也可以用于文件夾的移動(dòng)
File folder = new File("my new folder");
File newFolder = new File("my new folder -new");
// folder.renameTo(newFolder);//返回值為bool類型
if (folder.renameTo(newFolder)){
//可以單獨(dú)給每一級(jí)重命名
System.out.println("done");
} else {
System.out.println("fail");
}
刪除:?
File folder = new File("my new folder -new");
// folder.delete();只能刪除空文件夾
if(folder.delete()){
System.out.println("done");
}else{
System.out.println("fail");
}
文件屬性的讀取
File file = new File("test.txt");
在工程下手動(dòng)創(chuàng)建文件: 右擊項(xiàng)目名 - new - file
//判斷文件是否存在
System.out.println("判斷文件是否存在"+file.exists());
// //讀取文件名稱
System.out.println("讀取文件名稱"+file.getName());
// //讀取文件路徑
System.out.println("讀取文件路徑"+file.getPath());
// //讀取文件絕對(duì)路徑
System.out.println("讀取文件絕對(duì)路徑"+file.getAbsolutePath());
// //獲取文件父級(jí)路徑
System.out.println("獲取文件父級(jí)路徑"+new File(file.getAbsolutePath()).getParent());
// //讀取文件大小
System.out.println("讀取文件大小"+file.length()+"byte");
// //判斷文件是否被隱藏
System.out.println("判斷文件是否被隱藏"+file.isHidden());
// //判斷文件是否可讀
System.out.println("判斷文件是否可讀"+file.canRead());
// //判斷文件是否可寫(xiě)
System.out.println("判斷文件是否可寫(xiě)"+file.canWrite());
// //判斷文件是否為文件夾
System.out.println("判斷文件是否為文件夾"+file.isDirectory());
文件屬性的設(shè)置
File file = new File("test.file");
if(file.exists()){
//將文件設(shè)定為可寫(xiě)
file.setWritable(true);
//將文件設(shè)定為可讀
file.setReadable(true);
//將文件設(shè)定為只讀
file.setReadOnly();
}}
遍歷文件夾
? /Users/mac/Documents/workspace 是文件路徑
printFiles(new File("/Users/mac/Documents/workspace"));
文件路徑的查找: 在系統(tǒng)的文件瀏覽器中找到工程 ,顯示簡(jiǎn)介, 然后復(fù)制絕對(duì)路徑
}
//遍歷文件夾
public static void printFiles(File dir) {
//判斷當(dāng)前的dir是不是路徑
if (dir.isDirectory()){
//dir.listFiles() 返回的是一個(gè)file對(duì)象的數(shù)組
File next[] = dir.listFiles();
for (int i = 0; i < next.length; i++){
//如果是文件
if(next[i].isFile()){
//輸入名字
System.out.println(next[i].getName());
} else {
// 不是文件是文件夾, 則循環(huán)
printFiles(next[i]);
}}}}
或
public static void main(String[] args) {
// TODO Auto-generated method stub
printFiles(new File("../FileScaner"), 1);
}
//遍歷文件夾
public static void printFiles(File dir, int tab) {
//判斷當(dāng)前的dir是不是路徑
if (dir.isDirectory()){
//dir.listFiles() 返回的是一個(gè)file對(duì)象的數(shù)組
File next[] = dir.listFiles();
for (int i = 0; i < next.length; i++){
for (int j = 0; j < tab; j++){
System.out.print("|--");}
//輸入名字
System.out.println(next[i].getName());
//如果是文件夾
if(next[i].isDirectory()){
printFiles(next[i], tab + 1);}}}
文件的簡(jiǎn)單讀寫(xiě)
讀出文件:
public static void main(String[] args) {
File file = new File("text.txt");
//判斷文件存在
if (file.exists()){
System.out.println("exist");
//FileInputStream 文件輸入流
try {
//創(chuàng)建文件輸入流
FileInputStream fis = new FileInputStream(file);
//獲取了輸入流之后,需要將這個(gè)輸入流包裝成inputStreamReader
//InputStreamReader 字符流? 在字符和字節(jié)相互轉(zhuǎn)換的時(shí)候需要制定編碼類型
InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
//再創(chuàng)建一個(gè)帶有緩沖區(qū)的reader, 可以直接讀取一行數(shù)據(jù)
BufferedReader br = new BufferedReader(isr);
String line;//用來(lái)臨時(shí)存放讀取到的一行數(shù)據(jù)
while ((line = br.readLine())!=null) {
System.out.println(line);
}
br.close();
isr.close();
fis.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
寫(xiě)入文件
try {
File newfile = new File("newtext.txt");
//文件輸出流
FileOutputStream fos = new FileOutputStream(newfile);
//文件輸出流的writer
OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
//帶有緩沖區(qū)的writer
BufferedWriter bw = new BufferedWriter(osw);
//向文件中寫(xiě)入數(shù)據(jù)
bw.write("123\n");
bw.write("345\n");
bw.write("456\n");
//關(guān)閉輸出流
bw.close();
osw.close();
fos.close();
System.out.println("寫(xiě)入完成");