<div class="bbcodeblock bbcodequote bbcmspoilerblock">
<div class="attribution type"><noscript>bai 32 - tao phien ban kieu cmd (move your mouse to reveal the content)</noscript>
bai 32 - tao phien ban kieu cmd (open)
bai 32 - tao phien ban kieu cmd (close)
</div>
<div class="quotecontent">
<div class="bbcm_spoiler_noscript"><blockquote>
Mã nguồn PHP:
[color=#000000]
package baitapvenha[/color][color=#007700];[/color][color=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]io[/color][color=#007700].[/color][color=#0000bb]file[/color][color=#007700];[/color][color=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]io[/color][color=#007700].[/color][color=#0000bb]ioexception[/color][color=#007700];[/color][color=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]scanner[/color][color=#007700];[/color][color=#ff8000]/*** bài tập về nhà: (lần này mình giao bài khó khó chút nhé) tạo 1 chương trình* gần giống cmd trong ms-dos chạy trên màn hình console, chức năng như sau: -* bật chương trình lên mặc định vào ổ e (hoặc ổ nào tùy ý), hiện lên e:\\ (tên* đường đang hiện hành) - gõ "cd tenthumuc" thì màn hình chuyển và hiện lên* e:\\tenthumuc trong đó tenthumuc là tên thư mục tiếp tục muốn truy xuất. - gõ* "makefile tenfile" thì sẽ tạo file trong thư mục hiện hành, trong đó tenfile* là tên file cần tạo. - từ vị trí con trỏ hiện hành, gõ "show" thì hiển thị ra* toàn bộ cấu trúc cây thư mục trong thư mục đó. .... trình bày khá dài dòng* nhỉ, các bạn cứ cố gắng làm càng giống cmd trong ms-dos càng hay, bạn nào làm* xong nhớ share mọi người cùng tham khảo nhé*/ [/color][color=#007700]public class [/color][color=#0000bb]bai32_classfile [/color][color=#007700]{ public static [/color][color=#0000bb]void main[/color][color=#007700]([/color][color=#0000bb]string[/color][color=#007700][] [/color][color=#0000bb]args[/color][color=#007700]) [/color][color=#0000bb]throws ioexception [/color][color=#007700]{ [/color][color=#0000bb]scanner sc [/color][color=#007700]= new [/color][color=#0000bb]scanner[/color][color=#007700]([/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]in[/color][color=#007700]); [/color][color=#0000bb]string strfile[/color][color=#007700]; [/color][color=#0000bb]file checkdisk[/color][color=#007700][]; [/color][color=#0000bb]file f [/color][color=#007700]= new [/color][color=#0000bb]file[/color][color=#007700]([/color][color=#dd0000]"e:\\demofile"[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#0000bb]f[/color][color=#007700].[/color][color=#0000bb]getpath[/color][color=#007700]() + [/color][color=#dd0000]">"[/color][color=#007700]); [/color][color=#0000bb]boolean b [/color][color=#007700]= [/color][color=#0000bb]true[/color][color=#007700]; do { [/color][color=#0000bb]strfile [/color][color=#007700]= [/color][color=#0000bb]sc[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); if ([/color][color=#0000bb]strfile[/color][color=#007700].[/color][color=#0000bb]equalsignorecase[/color][color=#007700]([/color][color=#dd0000]"c:"[/color][color=#007700]) || [/color][color=#0000bb]strfile[/color][color=#007700].[/color][color=#0000bb]equalsignorecase[/color][color=#007700]([/color][color=#dd0000]"d:"[/color][color=#007700]) || [/color][color=#0000bb]strfile[/color][color=#007700].[/color][color=#0000bb]equalsignorecase[/color][color=#007700]([/color][color=#dd0000]"e:"[/color][color=#007700])) { [/color][color=#0000bb]f [/color][color=#007700]= new [/color][color=#0000bb]file[/color][color=#007700]([/color][color=#0000bb]strfile [/color][color=#007700]+ [/color][color=#dd0000]"\\"[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#0000bb]f[/color][color=#007700].[/color][color=#0000bb]getpath[/color][color=#007700]() + [/color][color=#dd0000]">"[/color][color=#007700]); } else if (([/color][color=#0000bb]strfile[/color][color=#007700].[/color][color=#0000bb]tolowercase[/color][color=#007700]()).[/color][color=#0000bb]startswith[/color][color=#007700]([/color][color=#dd0000]"cd"[/color][color=#007700])) { [/color][color=#0000bb]checkdisk [/color][color=#007700]= [/color][color=#0000bb]f[/color][color=#007700].[/color][color=#0000bb]listfiles[/color][color=#007700](); [/color][color=#0000bb]boolean check [/color][color=#007700]= [/color][color=#0000bb]true[/color][color=#007700]; for ([/color][color=#0000bb]int i [/color][color=#007700]= [/color][color=#0000bb]0[/color][color=#007700]; [/color][color=#0000bb]i [/color][color=#007700]< [/color][color=#0000bb]checkdisk[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++) { if ([/color][color=#0000bb]checkdisk[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]isdirectory[/color][color=#007700]() && [/color][color=#0000bb]strfile[/color][color=#007700].[/color][color=#0000bb]comparetoignorecase[/color][color=#007700]([/color][color=#dd0000]"cd " [/color][color=#007700]+ [/color][color=#0000bb]checkdisk[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]getname[/color][color=#007700]()) == [/color][color=#0000bb]0[/color][color=#007700]) { [/color][color=#0000bb]f [/color][color=#007700]= new [/color][color=#0000bb]file[/color][color=#007700]([/color][color=#0000bb]checkdisk[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]getpath[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"" [/color][color=#007700]+ [/color][color=#0000bb]f[/color][color=#007700].[/color][color=#0000bb]getpath[/color][color=#007700]() + [/color][color=#dd0000]">"[/color][color=#007700]); [/color][color=#0000bb]check [/color][color=#007700]= [/color][color=#0000bb]true[/color][color=#007700]; break; } else [/color][color=#0000bb]check [/color][color=#007700]= [/color][color=#0000bb]false[/color][color=#007700]; } if (![/color][color=#0000bb]check[/color][color=#007700]) { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"
access is fail
"[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"" [/color][color=#007700]+ [/color][color=#0000bb]f[/color][color=#007700].[/color][color=#0000bb]getpath[/color][color=#007700]() + [/color][color=#dd0000]">"[/color][color=#007700]); } } else if ([/color][color=#0000bb]strfile[/color][color=#007700].[/color][color=#0000bb]comparetoignorecase[/color][color=#007700]([/color][color=#dd0000]"show"[/color][color=#007700]) == [/color][color=#0000bb]0[/color][color=#007700]) { [/color][color=#0000bb]file f2 [/color][color=#007700]= new [/color][color=#0000bb]file[/color][color=#007700]([/color][color=#0000bb]f[/color][color=#007700].[/color][color=#0000bb]getpath[/color][color=#007700]()); do { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"
" [/color][color=#007700]+ [/color][color=#0000bb]f2[/color][color=#007700].[/color][color=#0000bb]getparent[/color][color=#007700]()); [/color][color=#0000bb]f2 [/color][color=#007700]= [/color][color=#0000bb]f2[/color][color=#007700].[/color][color=#0000bb]getparentfile[/color][color=#007700](); [/color][color=#0000bb]file [/color][color=#007700]list[] = [/color][color=#0000bb]f2[/color][color=#007700].[/color][color=#0000bb]listfiles[/color][color=#007700](); for ([/color][color=#0000bb]int i [/color][color=#007700]= [/color][color=#0000bb]0[/color][color=#007700]; [/color][color=#0000bb]i [/color][color=#007700]< list.[/color][color=#0000bb]length[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++) { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"
-->" [/color][color=#007700]+ list[[/color][color=#0000bb]i[/color][color=#007700]]); } } while ([/color][color=#0000bb]f2[/color][color=#007700].[/color][color=#0000bb]getparent[/color][color=#007700]() != [/color][color=#0000bb]null[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"
" [/color][color=#007700]+ [/color][color=#0000bb]f[/color][color=#007700].[/color][color=#0000bb]getpath[/color][color=#007700]() + [/color][color=#dd0000]">"[/color][color=#007700]); } else if ([/color][color=#0000bb]strfile[/color][color=#007700].[/color][color=#0000bb]comparetoignorecase[/color][color=#007700]([/color][color=#dd0000]"exit"[/color][color=#007700]) == [/color][color=#0000bb]0[/color][color=#007700]) { [/color][color=#0000bb]b [/color][color=#007700]= [/color][color=#0000bb]false[/color][color=#007700]; } else if ([/color][color=#0000bb]strfile[/color][color=#007700].[/color][color=#0000bb]tolowercase[/color][color=#007700]().[/color][color=#0000bb]startswith[/color][color=#007700]([/color][color=#dd0000]"makefile"[/color][color=#007700])) { [/color][color=#0000bb]string sub [/color][color=#007700]= [/color][color=#0000bb]strfile[/color][color=#007700].[/color][color=#0000bb]replace[/color][color=#007700]([/color][color=#dd0000]"makefile "[/color][color=#007700], [/color][color=#dd0000]""[/color][color=#007700]); [/color][color=#0000bb]f [/color][color=#007700]= new [/color][color=#0000bb]file[/color][color=#007700]([/color][color=#0000bb]f[/color][color=#007700], [/color][color=#0000bb]sub[/color][color=#007700]); [/color][color=#0000bb]f[/color][color=#007700].[/color][color=#0000bb]createnewfile[/color][color=#007700](); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"" [/color][color=#007700]+ [/color][color=#0000bb]f[/color][color=#007700].[/color][color=#0000bb]getpath[/color][color=#007700]() + [/color][color=#dd0000]">"[/color][color=#007700]); } else { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"'" [/color][color=#007700]+ [/color][color=#0000bb]strfile [/color][color=#007700]+ [/color][color=#dd0000]"' is not recognized as an internall or external command, operable program or batch file."[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#0000bb]f[/color][color=#007700].[/color][color=#0000bb]getpath[/color][color=#007700]() + [/color][color=#dd0000]">"[/color][color=#007700]); } } while ([/color][color=#0000bb]b [/color][color=#007700]== [/color][color=#0000bb]true[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"exit application!!!"[/color][color=#007700]); }}[/color]
</blockquote></div>
</div>
</div>
/*
* day la chuong trinh cua minh, moi nguoi check giúp minh nhé.
* chay ct thi ban doi ten file thu muc bat dau nhe
* 1. nhap c: ||d: ||e: || "cd <ten o dia>" de truy xuat o dia
* ==> trong truong hop k co thu muc ban nhap se hien thi "access fail"
* ==> nhap k dung quy dinh(1) se yeu cau nhap lai
* 2. nhap 'makefile ' de tao file moi
* 3. nhap 'show' de xem toan bo cau truc cay thu muc
* 4. nhap 'exit' neu ban muon thoat chuong trinh
* ==> tat ca ki tu ban nhap khong phan biet 'hoa' va 'thuong'
*/
Bạn muốn tạo nên một không gian phòng ngủ ấm cúng, sang trọng và bền bỉ theo thời gian? Bộ giường tủ phòng ngủ gỗ tự nhiên Hoàng Vân là lựa chọn hoàn hảo, kết hợp giữa thẩm mỹ và chất lượng vượt...
Bộ Giường Tủ Phòng Ngủ Gỗ Tự Nhiên – Vẻ Đẹp Sang Trọng, Tinh Tế