對輸入和輸出的初略學習

導語:java

===================================sql

無論你承不認可,跟不跟進,docker

各類IT應用組件的Docker容器化大潮,數組

已撲面而來。oracle

而基於docker之上頂層的k8s調度和編排,this

已然成爲國內各類IT應用的趨勢。url

而在咱們平安證券內部,spa

FAT環境建設,UAT環境建設,命令行

K8S與棱鏡PRISM的自動化部署的集成,code

正如火如荼展開。

向容器技術遷徙的步伐,

已不可中止!

 

而你,只是你,一個熟悉傳統虛擬機上開發應用的你,

準備好了麼???

注:Statement類的,這個對象是執行SQL語句的對象--resultset=    statement.executeQuery(sql);將查詢到的結果放到ResultSet結果集中


orcal.driverName=oracle.jdbc.driver.OracleDriver
PA18dburl=jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = spa181.dbstg.paic.com.cn)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST =spa182.dbstg.paic.com.cn)(PORT = 1521))(LOAD_BALANCE = yes)(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = hsspa18)(FAILOVER_MODE = (TYPE = SELECT)(METHOD = BASIC)(RETRIES = 180)(DELAY = 5))))
PA18dbuser=sisopr
PA18sdbpsw=pasc_stg_pa18
 

package properties;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

import javax.swing.JFrame;
import javax.swing.JLabel;


public  class Test1 {
	public static void main(String[] args) {
		//如下是Set接口的實例
/*Set<String> s=new HashSet<String>();
for (String a:args){
	if(!s.add(a)){
		System.out.println("重複的元素:"+a);
		
       }
	System.out.println(s.size()+"個單獨的單詞:"+s);//i b i c i d e
}*/
	//如下是生成彈框實例	
	/*javax.swing.SwingUtilities.invokeLater(new Runnable(){
		public void run(){
			createAndShowGUI();	
		}
	});
		
	}*/
		
	/*private static void createAndShowGUI(){
		JFrame frame=new JFrame("helloworldSwing");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		JLabel label=new JLabel("hello world");
		frame.getContentPane().add(label);
		frame.pack();
		try {
			frame.setVisible(true);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		*/
		//如下是對字節流和字符流的處理實例
		//FileInputStream的實例
		
	/*	try {
			FileInputStream in=new FileInputStream("201712101711485.txt");
			int n=200;
			byte buffer[] =new byte[n];
			while((in.read(buffer, 0, n))!=-1 &&(n>0)){
				System.out.println(new String(buffer));
			}
			System.out.println();
			in.close();
		} catch (IOException ioe) {
			// TODO Auto-generated catch block
			ioe.printStackTrace();
		}catch(Exception e){
			System.out.println(e);
		}*/
		
		//FileOutputStream的實例
	/*	System.out.println("請輸入要保存文件的內容:");
		int count,n=512;
		byte[] buffer=new byte[n];
		try {
			count=System.in.read(buffer);
			//FileOutputStream os=new FileOutputStream("201712101711485.txt",true);//這是表明在原文件中添加數據,不覆蓋原文件內容
		FileOutputStream os=new FileOutputStream("tt.txt");
			os.write(buffer, 0, count);//直接以上tt.txt文件,並把數組buffer中的長度爲count的字節寫入流中
			os.close();
			System.out.println("已保存到201712101711485.txt");
		} catch (IOException ioe) {
			// TODO Auto-generated catch block
			ioe.printStackTrace();
		}catch(Exception e){
			System.out.println(e);
		}*/
		
		//system.in標準輸入流 能夠包裝成字節流或者字符流都可 好比字符流 你輸入字符
		//一般狀況下,你會用readLine( )一行一行地讀取輸入,所以要把System.in包裝成BufferedReader。但在這以前還得先用InputSteamReader把System.in轉換成Reader。
		/*BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		
		try {
			str = br.readLine();
			System.out.println(str);//打印str
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
		
		
		/*try {
		//System.in.read()能夠實現輸入字符,返回字符的Unicode碼,可是缺點是隻能輸入一個字符
		int a=System.in.read();
		System.out.println(a);
	} catch (IOException e1) {
		// TODO Auto-generated catch block
		e1.printStackTrace();
	}*/
		
	//FileReader類-用於讀取文件,讀取字符,上面那個FileInputStream讀取字節
		//建立一個FileReader類型的對象
		/*FileReader fr;
		try {
			fr = new FileReader("tt.txt");//該tt.txt已存在
			int c;
			try {
				c = fr.read();
				while (c!=-1){
					System.out.println((char) c);
					c=fr.read();
			}
				fr.close();
			}catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
		
		}catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
		
		//FileWriter類
		/*FileWriter fw;
		try {
			fw = new FileWriter("tt.txt",true);//加上 true參數,表明是往這個文件中添加 內容,不是覆蓋原文件的內容
			fw.write("this is my");
			fw.write("stu");
			fw.write("dent");
			fw.write(".");
			fw.write("txt");
			fw.write("這是個人文件");
			fw.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
		
		/*public static void main(String[] args) throws IOException{//這裏有拋出異常後,方法中可不須要處理異常了
			FileWriter fw;

				fw = new FileWriter("tt.txt",true);//加上 true參數,表明是往這個文件中添加 內容,不是覆蓋原文件的內容
				fw.write("this is my");
				fw.write("stu");
				fw.write("dent");
				fw.write(".");
				fw.write("txt");
				fw.write("這是個人文件");
				fw.close();
			
		}
		}
		*/
		
		//BufferedReader和 BufferedWriter類--緩衝讀、寫器
		/*FileReader fr;
		try {
			fr = new FileReader("tt.txt");
			BufferedReader br=new BufferedReader(fr);//這裏是把fr這個流再接到另一個流上,從後一個流中讀取名單
			String s=br.readLine();//建立變量S用於在存儲從文件中讀取的第一行數據
			while(s!=null){//判斷S變量是否接收到數據
				System.out.println(s+"\n");
			s=br.readLine();//讀取下 一行數據並存儲到S中
			}
			br.close();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
		
		
		/*try {
			BufferedWriter bw=new BufferedWriter(new FileWriter("tt.txt"));
			bw.write("hello nihao1");//向文件中寫入字符串
			bw.newLine();//換行
			bw.write("這是個人文件");//向文件中寫入內容
			bw.close();//關閉流
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
		
		//使用System.in獲取用戶輸入
		/*int a;
		System.out.println("請輸入一個字符:");
		try {
			a=(char) System.in.read();//獲取鍵盤輸入並存入變量a中
			System.out.println("你輸入的字符是:"+a);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		*/
		
		//使用Scanner類獲取用戶輸入,可以使用該類建立一個從命令行讀取數據的對象,而沒必要再進行流的轉換
		/*System.out.println("請輸入若干個數,每 輸入一個數按回車鍵 確認");
		System.out.println("最後輸入一個非數字結束輸入操做");
		//建立讀取命令行內容的Scanner對象
		Scanner reader=new Scanner(System.in);
		double sum=0;
		int m=0;
		while(reader.hasNextDouble()){//若是持續讀入數據,就是來判斷是否還有後續的double類型的輸入內容
			double x=reader.nextDouble();//將讀入的字符串轉化爲小數
			m=m+1;
			sum=sum+x;			
		}
		System.out.println(m+"個數的和爲:"+sum);
		System.out.println(m+"個數的平均值:"+sum/m);
		*/
	}
	

	
}
相關文章
相關標籤/搜索