diff --git a/README.TXT b/README.TXT new file mode 100644 index 0000000..8327d5b --- /dev/null +++ b/README.TXT @@ -0,0 +1,13 @@ +======================== +BUILD OUTPUT DESCRIPTION +======================== + + + +1- Pour lancer l'application, commencer tout d'abord par vous rendre dans votre terminal de commande. + +2- Rendez vous dans C:\...\ngetv1\dist + +3- Une fois placer dans le dossier, utilisez la commande java -jar ngetv1.jar + +L'application est désormais lancée. \ No newline at end of file diff --git a/ngetv1/build.xml b/ngetv1/build.xml new file mode 100644 index 0000000..cdba3ef --- /dev/null +++ b/ngetv1/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project ngetv1. + + + diff --git a/ngetv1/dist/README.TXT b/ngetv1/dist/README.TXT new file mode 100644 index 0000000..b5e594b --- /dev/null +++ b/ngetv1/dist/README.TXT @@ -0,0 +1,32 @@ +======================== +BUILD OUTPUT DESCRIPTION +======================== + +When you build an Java application project that has a main class, the IDE +automatically copies all of the JAR +files on the projects classpath to your projects dist/lib folder. The IDE +also adds each of the JAR files to the Class-Path element in the application +JAR files manifest file (MANIFEST.MF). + +To run the project from the command line, go to the dist folder and +type the following: + +java -jar "ngetv1.jar" + +To distribute this project, zip up the dist folder (including the lib folder) +and distribute the ZIP file. + +Notes: + +* If two JAR files on the project classpath have the same name, only the first +JAR file is copied to the lib folder. +* Only JAR files are copied to the lib folder. +If the classpath contains other types of files or folders, these files (folders) +are not copied. +* If a library on the projects classpath also has a Class-Path element +specified in the manifest,the content of the Class-Path element has to be on +the projects runtime path. +* To set a main class in a standard Java project, right-click the project node +in the Projects window and choose Properties. Then click Run and enter the +class name in the Main Class field. Alternatively, you can manually type the +class name in the manifest Main-Class element. diff --git a/ngetv1/dist/ngetv1.jar b/ngetv1/dist/ngetv1.jar new file mode 100644 index 0000000..6de63db Binary files /dev/null and b/ngetv1/dist/ngetv1.jar differ diff --git a/ngetv1/manifest.mf b/ngetv1/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/ngetv1/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/ngetv1/nbproject/build-impl.xml b/ngetv1/nbproject/build-impl.xml new file mode 100644 index 0000000..a1dc911 --- /dev/null +++ b/ngetv1/nbproject/build-impl.xml @@ -0,0 +1,1407 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ngetv1/nbproject/genfiles.properties b/ngetv1/nbproject/genfiles.properties new file mode 100644 index 0000000..2d168ec --- /dev/null +++ b/ngetv1/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=d1f0e7f6 +build.xml.script.CRC32=e289bffa +build.xml.stylesheet.CRC32=8064a381@1.68.1.46 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=d1f0e7f6 +nbproject/build-impl.xml.script.CRC32=388073d2 +nbproject/build-impl.xml.stylesheet.CRC32=5a01deb7@1.68.1.46 diff --git a/ngetv1/nbproject/private/private.properties b/ngetv1/nbproject/private/private.properties new file mode 100644 index 0000000..1a59211 --- /dev/null +++ b/ngetv1/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=C:\\Users\\Younouss\\AppData\\Roaming\\NetBeans\\7.4\\build.properties diff --git a/ngetv1/nbproject/private/private.xml b/ngetv1/nbproject/private/private.xml new file mode 100644 index 0000000..207d6c0 --- /dev/null +++ b/ngetv1/nbproject/private/private.xml @@ -0,0 +1,9 @@ + + + + + + file:/C:/Users/Younouss/Documents/Students-niang-younouss-nget-v1/ngetv1/src/ngetv1/Ngetv1.java + + + diff --git a/ngetv1/nbproject/project.properties b/ngetv1/nbproject/project.properties new file mode 100644 index 0000000..dbeefd4 --- /dev/null +++ b/ngetv1/nbproject/project.properties @@ -0,0 +1,73 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/ngetv1.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.7 +javac.target=1.7 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=ngetv1.Ngetv1 +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/ngetv1/nbproject/project.xml b/ngetv1/nbproject/project.xml new file mode 100644 index 0000000..0084f15 --- /dev/null +++ b/ngetv1/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + ngetv1 + + + + + + + + + diff --git a/ngetv1/src/ngetv1/Ngetv1.java b/ngetv1/src/ngetv1/Ngetv1.java new file mode 100644 index 0000000..c62bd3c --- /dev/null +++ b/ngetv1/src/ngetv1/Ngetv1.java @@ -0,0 +1,124 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package ngetv1; + +import java.io.BufferedInputStream; +import java.io.BufferedWriter; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.Scanner; + +/** + * + * @author Younouss + */ +public class Ngetv1 { + + /** + * @param args the command line arguments + * @throws java.io.FileNotFoundException + * @throws java.io.IOException + */ + @SuppressWarnings("empty-statement") + public static void main(String[] args) throws FileNotFoundException, IOException { + // TODO code application logic here + System.out.println("Veuillez entrer votre ligne de commande"); + + Scanner scan = new Scanner(System.in); + String commande = scan.nextLine(); + String[] commandeSplited = commande.split("\\s+"); + + switch (commandeSplited[1]) { + case "get": + String url = commandeSplited[3].replaceAll("\"",""); + System.out.println(url); + HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); + conn.connect(); + + BufferedInputStream bis = new BufferedInputStream(conn.getInputStream()); + + byte[] bytes = new byte[1024]; + int tmp ; + if(commandeSplited.length<4) + System.out.println("Erreur, la commande doit être du format: nget.exe get -url \"MonUrl\" "); + if(commandeSplited.length==4) + { + while( (tmp = bis.read(bytes) ) != -1 ) + { + String chaine = new String(bytes,0,tmp); + System.out.println(chaine); + } + } + else if(commandeSplited.length>4 && (commandeSplited[4].replaceAll("-","")).equals("save")) + { + String path = commandeSplited[5].replaceAll("\"",""); + try + { + + FileWriter fw = new FileWriter(path, true); + try (BufferedWriter output = new BufferedWriter(fw)) { + while( (tmp = bis.read(bytes) ) != -1 ) + { + String chaine = new String(bytes,0,tmp); + output.write(chaine); + output.write("\r\n"); + } + output.flush(); + } + System.out.println("fichier créé"); + } + catch(IOException ioe){ + System.out.print("Erreur : "); + } + + } + conn.disconnect(); + break; + case "test": + String url2 = commandeSplited[3].replaceAll("\"",""); + HttpURLConnection connect = (HttpURLConnection) new URL(url2).openConnection(); + int timeVal = Integer.valueOf(commandeSplited[5]); + long startTime,moy=0; + if(commandeSplited.length<6) + System.out.println("Erreur, la commande doit être du format: nget.exe test -url \"MonUrl\" -times MaValeur"); + else if(commandeSplited.length==6) + { + if(timeVal > 0) + { + for(int i=0; i< timeVal;++i) + { + startTime = System.currentTimeMillis(); + connect.connect(); + System.out.println("Temps de chargement "+i+": "+ (System.currentTimeMillis() - startTime)); + connect.disconnect(); + } + } + else System.out.println("Erreur, veuillez indiquer un nombre positif"); + } + else if(commandeSplited.length>=7 && (commandeSplited[6].replaceAll("-","")).equals("avg")) + { + if(timeVal > 0) + { + for(int i=0; i< timeVal;++i) + { + startTime = System.currentTimeMillis(); + connect.connect(); + moy = moy+ System.currentTimeMillis() - startTime; + connect.disconnect(); + } + moy = moy/timeVal; + System.out.println("Temps de chargement moyen de chargement: "+ moy); + } + else System.out.println("Erreur, veuillez indiquer un nombre positif"); + } + break; + } + } +}