Created
March 13, 2022 16:57
-
-
Save albertopasqualetto/2d46ef7979064be4afa3759822605052 to your computer and use it in GitHub Desktop.
Transforms list of urls file into bookmark html file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.Scanner; | |
public class Bookmarkify{ | |
//argv[0] is a list of urls file | |
//output file is created in the actual terminal directory | |
public static void main(String[] argv) throws FileNotFoundException, IOException{ | |
FileReader fr=new FileReader(argv[0]); | |
BufferedReader br = new BufferedReader(fr); | |
Scanner s= new Scanner(br); | |
FileWriter fw= new FileWriter("Bookmarks from "+argv[0]+".html"); | |
PrintWriter w=new PrintWriter(fw); | |
w.println("DOCTYPE NETSCAPE-Bookmark-file-1>"); | |
w.println("<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">"); | |
w.println("<DL><p>"); | |
w.println("\t<DT><H3>New Imported folder</H3></DT>"); | |
w.println("\t<DL><p>"); | |
while (s.hasNext()){ | |
String url= s.nextLine(); | |
String title=url; | |
title=url.replace("https://www.", ""); //Basic title cleaning | |
title= url.replace("https://", ""); | |
w.println("\t\t<DT><A HREF=\""+url+"\">"+title+"</A></DT>"); | |
} | |
w.println("\t</DL><p>"); | |
w.println("</DL><p>"); | |
s.close(); | |
w.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment