Java generate a website 🌐

preview_player
Показать описание
Java web page,
Java web page example,
Java web page development,
Java web development,
Java web development tutorial,
Java web projects,
Java website tutorial,
Java website generate,
Java HTML tutorial,
Java HTML printwriter,
Рекомендации по теме
Комментарии
Автор

import java.io.*;
import java.util.*;

public class Main {

public static void main(String[] args) {

// HTML stands for "Hyper Text Markup Language"
// used for creating web pages

// 1. ask user for a file name
// 2. check if file exists
// 3. rename .txt as .html
// 4. determine if file is empty
// 5. read each line and insert necessary <tags>

Scanner scanner = new Scanner(System.in);
Scanner fileIn; //input file connection
PrintWriter fileOut; //HTML file connection
String filenameIn; //original file's name
String filenameOut; //new HTML file's name
int dotIndex; //position of . in filename
String line = null; // a line from the input file

// 1. ask user for a file name (or file path)

System.out.println("Enter file name or path");
filenameIn = scanner.nextLine();

// 2. check if file exists

try {

//3. rename .txt as .html
fileIn = new Scanner(new FileReader(filenameIn));
dotIndex = filenameIn.lastIndexOf(".");
if(dotIndex == -1) {
filenameOut = filenameIn + ".html";
}
else {
filenameOut = filenameIn.substring(0, dotIndex) + ".html";
}
fileOut = new PrintWriter(filenameOut);

// 4. determine if file is empty

try {
line = fileIn.nextLine();
}
e) {
"+e.getMessage());
}
if(line==null) {
System.out.println("This file is empty :(");
}
else {
// 5. read each line and insert necessary <tags>




fileOut.println(line);

{


= fileIn.nextLine();

{


{



}



System.out.println("HTML file is processed :)");
}
fileIn.close();
fileOut.close();
}
catch(FileNotFoundException e) {
System.out.println("File not found");
}

}
}

BroCodez
Автор

I've been watching your videos for the past 2 or 3 weeks now and I can't believe that your videos get so little attention. You deserve 100x the attention on this platform :)

Dygit
Автор

Your content was good ever since the beginning hence you did succeed

Tozu
Автор

People are really missing out on these tutorials.

RipperRoo
Автор

thnx very much bro even though i know HTML i love this toturial

rayyan-gx
Автор

Very nice! Thanks for this tutorial 🤟🏽

thexmorfeu
Автор

Your the type of coder that makes coding fun! 😊

Xayles_
Автор

This demo is very good, but there are too many code. If we use dom4j, we can use only 5 lines code to read any HTML or xml or anything else.

girl
Автор

Bro thanks for this videos ☺️i have created by watching your videos

prabuddhapal
Автор

Hey bro. you are my teacher.... I would like to know as much as you do in java programming. I wonder how is the education in the united states. In ecuador, it is not that good.

ChristianRodriguez-tmjg
Автор

HI! so am I able to upload an entire java program like this? for example if I built a game that used multiple java files, would I be able to upload them all to a website and have my program run on there?

craigbenjamin
Автор

Can we make it using other IDEs like IntelliJ and NetBeans?

arshmandal
Автор

I refreshed but the .html file didn't pop up...

mukandeinc
Автор

For some reason, it always says "File not found" even after I copied your code, the error is the same.

bmfjrccarspartsandhowtob