java檔案讀寫常用方法

來源:互聯網
上載者:User

標籤:nan   exec   reader   buffered   auto   exe   none   space   cep   

// TODO Auto-generated method stub
//File file = new File("D:\\Android\\workspace\\Practice1\\src\\test4", "new1.txt");
//String str = file.getName();
//file.delete();

//try{
//Runtime rt = Runtime.getRuntime();
//
//File file = new File("D:\\Program Files (x86)\\CodeBlocks", "codeblocks.exe");
//System.out.println("開啟codeblocks");
//rt.exec(file.getAbsolutePath());
//file = new File("D:\\酷狗\\KGMusic", "KuGou.exe");
//System.out.println("開啟酷狗");
//rt.exec(file.getAbsolutePath());
//file = new File("D:\\淨網大師\\ADSafe", "ADSafeSvc.exe");
//System.out.println("開啟淨網大師");
//rt.exec(file.getAbsolutePath());
//}catch(Exception e){
//System.out.println(e);
//}


//try{
//File f = new File("D:\\Android\\workspace\\Practice1\\src\\test4", "file.txt");
//FileInputStream in = new FileInputStream(f);
//int n = -1;
//byte [] a= new byte[100];
//
//while((n = in.read(a, 0, 100)) != -1){
//String s = new String(a, 0, n);
//System.out.print(s);
//}
//in.close();
//}
//catch(Exception e){
//System.out.println(e);
//}

//try{
//byte []b = "我是你爸爸".getBytes();
//File file = new File("D:\\Android\\workspace\\Practice1\\src\\test4", "empty.txt");
//FileOutputStream out = new FileOutputStream(file);
//out.write(b);
//out.close();
//out = new FileOutputStream(file, true);
//b = ",當檔案字元輸出資料流的構造方法中有true參數時,可以在檔案末尾追加文字".getBytes();
//out.write(b);
//
//out.close();
//
//}
//catch(Exception e){
//System.out.println(e);
//}

//byte []b = "我是你大爺".getBytes();
//System.out.println(b);

//File sourceFile = new File("D:\\Android\\workspace\\Practice1\\src\\test4","a.txt");
//File targetFile = new File("D:\\Android\\workspace\\Practice1\\src\\test4","b.txt");
//
//char c[] = new char[19];
//try{
//Reader in = new FileReader(sourceFile);
//Writer out = new FileWriter(targetFile, true);
//int n = -1;
//while((n = in.read(c))!= -1){
//out.write(c, 0, n);
//}
//out.flush();//使緩衝區的內容馬上寫入目的地
//out.close();
//}catch(Exception e){
//System.out.println(e);
//
//}

//try{
//
//FileReader inOne = new FileReader("D:\\Android\\workspace\\Practice1\\src\\test4\\a.txt");
//BufferedReader bufferedRead = new BufferedReader(inOne);
//
//FileWriter tofile = new FileWriter("D:\\Android\\workspace\\Practice1\\src\\test4\\to.txt");
//BufferedWriter bufferedWrite = new BufferedWriter(tofile);
//
//String str = null;
//
//while((str = bufferedRead.readLine()) != null){
//StringTokenizer fenxi = new StringTokenizer(str);
//str = str + "單詞個數:" + fenxi.countTokens();
//bufferedWrite.write(str);
//bufferedWrite.newLine();
//}
//
//bufferedWrite.close();
//tofile.close();
//bufferedRead.close();
//inOne.close();
//
//
//}
//catch(Exception e){
//System.out.println(e);
//}

//
//RandomAccessFile inAndOut = null;
//int data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 111};
//try{
//inAndOut = new RandomAccessFile("D:\\Android\\workspace\\Practice1\\src\\test4\\random.txt", "rw");
//for(int i = 0; i < data.length; i++){
//inAndOut.writeInt(data[i]);
//}
//
//for(long i = data.length - 1; i >= 0; i--){
//inAndOut.seek(i * 4);
//System.out.printf("\t%d", inAndOut.readInt());
//}
//inAndOut.close();
//}catch(Exception e){
//System.out.println(e);
//}
//

System.out.println(Math.round(-13.4));
char 壞 = ‘壞‘;

ok:while(true){
while(true){
System.out.println("我只迴圈一次");
break ok;
}
}

int num = (int)Math.random() * 100;


//break String s = null;
//char 好 = 壞;

}

java檔案讀寫常用方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.