Youtube Video Downloader - Online earn with games

Breaking

BANNER 728X90

Tuesday, March 28, 2023

Youtube Video Downloader

String videoURL = "https://www.youtube.com/watch?v=VIDEO_ID_HERE"; // Masukkan URL video YouTube di sini String saveAs = "video.mp4"; // Nama file video yang akan disimpan try { URL url = new URL("https://www.youtubeinmp4.com/redirect.php?video=" + videoURL); // Mengubah URL video menjadi URL yang dapat diunduh HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.connect(); InputStream inputStream = connection.getInputStream(); // Membaca data video dari koneksi FileOutputStream outputStream = new FileOutputStream(saveAs); byte[] buffer = new byte[4096]; int length; while ((length = inputStream.read(buffer)) != -1) { // Menyalin data ke file video outputStream.write(buffer, 0, length); } outputStream.close(); inputStream.close(); System.out.println("Video berhasil diunduh!"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }

No comments:

Post a Comment