Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.io.UnsupportedEncodingException;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import java.util.logging.ConsoleHandler;
- import java.util.logging.FileHandler;
- import java.util.logging.Handler;
- public class Main {
- /**
- * lance le programme
- * @param args les paramatres saisis
- */
- private static final Logger LOGGER = Logger.getLogger(Main.class.getName());
- public static void main(String[] args){
- LOGGER.info("Logger Name: "+LOGGER.getName());
- System.getProperties().setProperty("http.proxyHost", "squidva.univ-ubs.fr");
- System.getProperties().setProperty("http.proxyPort", "3128");
- System.getProperties().setProperty("https.proxyHost", "squidva.univ-ubs.fr");
- System.getProperties().setProperty("https.proxyPort", "3128");
- try(
- FileWriter fw = new FileWriter(new File(args[1]))){
- Handler consoleHandler = new ConsoleHandler();
- Handler fileHandler = new FileHandler("./logger.log");
- LOGGER.addHandler(consoleHandler);
- LOGGER.addHandler(fileHandler);
- consoleHandler.setLevel(Level.ALL);
- fileHandler.setLevel(Level.ALL);
- LOGGER.setLevel(Level.ALL);
- LOGGER.fine("Création d'un fichier "+ args[1]);
- if(args.length == 3) {
- IOUtilities.copyInto(RemoveTagsReader.Remove(HTTPUtilities.readHTML(new URL(args[0]))), fw);
- LOGGER.fine("Copie de "+ args[0] + "Sans tag <*> ");
- }else if(args.length == 4 ) {
- IOUtilities.copyInto(RemoveTagsReader.Remove(RemoveWhitesReader.Remove(HTTPUtilities.readHTML(new URL(args[0])))), fw);
- LOGGER.fine("Copie de "+ args[0] + "Sans espaces et tag <*> ");
- }else{
- IOUtilities.copyInto(HTTPUtilities.readHTML(new URL(args[0])), fw);
- LOGGER.fine("Copie de "+ args[0]);
- }
- } catch (UnsupportedEncodingException e) {
- LOGGER.log(Level.SEVERE, "Exception occur", e);
- e.printStackTrace();
- } catch (MalformedURLException e) {
- LOGGER.log(Level.SEVERE, "Exception occur", e);
- e.printStackTrace();
- } catch (IOException e) {
- LOGGER.log(Level.SEVERE, "Exception occur", e);
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement