CÔNG VIỆC CỦA CHÚNG TÔI

+ Đào tạo & hỗ trợ thi & Cấp chứng chỉ Ứng dụng CNTT cơ bản, nâng cao
+ Cung cấp dịch vụ Thiết kế - Lập trình web
+ Các giải pháp triển khai - quản trị hệ thống mạng doanh nghiệp
+ ĐÀO TẠO CHUYÊN NGHIỆP: LẬP TRÌNH (C, .Net, ASP.net, PHP, Thiết kế Đồ họa
Hiển thị các bài đăng có nhãn URL. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn URL. Hiển thị tất cả bài đăng
Thực hành Lập trình mạng - URL - Bài 3 - Download mã HTML

Thực hành Lập trình mạng - URL - Bài 3 - Download mã HTML

Chương trình download mã HTML một trang web và lưu lên máy
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;

public class DownloadHTMLFile {

public static void main(String[] args) {
// TODO Auto-generated method stub
try {
URL u = new URL("http://centrasd.edu.vn");
// Lấy về luồng nhập
InputStream inputWeb = u.openStream();
// Xử lý luồng, và in ra màn hình
InputStreamReader reader = new InputStreamReader(inputWeb);
BufferedReader buff = new BufferedReader(reader);
FileWriter fw = new FileWriter("e:\\abc.html");
BufferedWriter dau_ghi = new BufferedWriter(fw);
while (true) {
String line = buff.readLine();
if (line ==null)  break;
else{
dau_ghi.write(line);
dau_ghi.newLine();
}
}
} catch (MalformedURLException e) {
System.out.println("Định dạng URL bị sai"); 
} catch (IOException e) {
System.out.println("Lỗi khi truy xuất luồng"); 
}
}
}
 
Thực hành Lập trình mạng - URL - Bài 2 - Đọc mã HTML

Thực hành Lập trình mạng - URL - Bài 2 - Đọc mã HTML

Viết chương trình liệt kê toàn bộ nội dung của bất kì trang web nào trên netChức năng chương trình:- Hiển thị thông tin toàn bộ trang web của bất kì trang web nào dưới dạng text đơn thuần
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;

public class DocNoiDungTrangWeb {

public static void main(String[] args) {
// TODO Auto-generated method stub
try {
URL u = new URL("http://centrasd.edu.vn");
// Lấy về luồng nhập
InputStream inputWeb = u.openStream();
// Xử lý luồng, và in ra màn hình
InputStreamReader reader = new InputStreamReader(inputWeb);
BufferedReader buff = new BufferedReader(reader);
while (true) {
String line = buff.readLine();
if (line ==null)  break;
else 
System.out.println(line);
}
} catch (MalformedURLException e) {
System.out.println("Định dạng URL bị sai"); 
 } catch (IOException e) {
System.out.println("Lỗi khi truy xuất luồng"); 
}
}
}
 
Thực hành lập trình mạng-URL- bài 1

Thực hành lập trình mạng-URL- bài 1

Đề bài: Viết chương trình xử lí chuỗi nhập, dùng nó để khởi tạo đối tượng URL và trả về thuộc tính của nó 
Chức năng chương trình:- Truy cập vào URL, sau đó in các thông tin của tài nguyên như:o Tên fileo Tên hosto Số hiệu cổngo Kiểu giao thức (https hoặc http hoặc ftp…)

import java.net.*;
import java.util.Scanner;

public class URL_Bai1 {

public static void main(String[] args) {
Scanner banphim = new Scanner(System.in);
System.out.println("Nhập tên file");
String tenfile = banphim.nextLine();
System.out.println("Nhập tên host");
String tenHost= banphim.nextLine();
System.out.println("Số hiệu cổng");
int soCong= Integer.parseInt( banphim.nextLine() );   // ĐỔi chuỗi thành số
System.out.println("Giao thức");
String giaothuc = banphim.nextLine();
try {
URL u = new URL(giaothuc,tenHost, soCong, tenfile);
System.out.println("Giao thức: "+u.getProtocol());
System.out.println("Host: "+u.getHost());
System.out.println("Cổng: "+u.getPort());
System.out.println("File: "+u.getFile());
System.out.println("Full Path: "+u.getPath());
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
}