GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||
GeezerVison is showing raw.githubusercontent.com — raw.githubusercontent.com import java.io.*;
/*
Used to generate table of contents.
- No args: generate GitHub table
- args == 'wordpress', generate WordPress table.
- args == 'review', generate Review Page
- args == 'all', genereate both table
*/
public class GenerateCodeTable {
public final static String TUTORIAL_KEY_WORD = "tutorial:";
public static void main(String[] args) {
//Read Java Solution Folder
File folder = new File("./Java");//"." = current path
if (!folder.exists() || !folder.isDirectory()) {
System.out.println("Check Directory:1");
return;
}
File[] listOfFiles = folder.listFiles();
if (listOfFiles == null) {
System.out.println("Check Directory:2");
return;
}
String outputContent = "";
File outFile;
if (args.length == 0){
outputContent = generateREADME(listOfFiles);
printTable("README.md", outputContent);
} else if (args != null && args[0].contains("wordpress")) {//Wordpress
outputContent = generateWordPressPage(listOfFiles);
printTable("WordPress.txt", outputContent);
} else if (args != null && args[0].contains("review")) {//Review Page
outputContent = generateReviewPage(listOfFiles);
printTable("ReviewPage.md", outputContent);
} else if (args != null && args[0].contains("all")) {
outputContent = generateREADME(listOfFiles);
printTable("README.md", outputContent);
outputContent = generateWordPressPage(listOfFiles);
printTable("WordPress.txt", outputContent);
outputContent = generateReviewPage(listOfFiles);
printTable("ReviewPage.md", outputContent);
} else {
return;
}
}
/*
Output the content into file
*/
public static void printTable(String fileName, String outputContent) {
System.out.println(outputContent);
//Write to README.md
try {
File outFile = new File(fileName);
FileOutputStream fop = new FileOutputStream(outFile);
byte[] contentInBytes = outputContent.getBytes();
fop.write(contentInBytes);
fop.flush();
fop.close();
System.out.println("Mission Accomplished. Now go ahead and commit");
} catch (IOException e) {
e.printStackTrace();
}
}
/*
Generate Wordpress contents
*/
public static String generateWordPressPage(File[] listOfFiles) {
//Assemble output
String outputContent = "Java Solutions to algorithm problems from LintCode, LeetCode...etc.\n" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"";
int count = 0;
for (File file : listOfFiles) {
if (file.getName().contains(".java")) {
//outputContent += "|" + count + "|[" + file.getName() + "](https://github.com/shawnfan/LintCode/blob/master/Java/"+ file.getName() +")| |" + "Java|\n";
outputContent+=
"" +
"" +
"" +
"" +
"" +
"";
count++;
}
}
outputContent += "
| ||||||||
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |