diff --git a/ClientHttp/build.xml b/ClientHttp/build.xml new file mode 100644 index 0000000..5509b5d --- /dev/null +++ b/ClientHttp/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project ClientHttp. + + + diff --git a/ClientHttp/build/built-jar.properties b/ClientHttp/build/built-jar.properties new file mode 100644 index 0000000..6dfc0d4 --- /dev/null +++ b/ClientHttp/build/built-jar.properties @@ -0,0 +1,4 @@ +#Thu, 09 Mar 2023 13:05:49 +0100 + + +/home/docente/Progetti/ClientHttp= diff --git a/ClientHttp/build/classes/.netbeans_automatic_build b/ClientHttp/build/classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29 diff --git a/ClientHttp/build/classes/.netbeans_update_resources b/ClientHttp/build/classes/.netbeans_update_resources new file mode 100644 index 0000000..e69de29 diff --git a/ClientHttp/build/classes/clienthttp/ClientHttp.class b/ClientHttp/build/classes/clienthttp/ClientHttp.class new file mode 100644 index 0000000..689215e Binary files /dev/null and b/ClientHttp/build/classes/clienthttp/ClientHttp.class differ diff --git a/ClientHttp/dist/ClientHttp.jar b/ClientHttp/dist/ClientHttp.jar new file mode 100644 index 0000000..47af1fe Binary files /dev/null and b/ClientHttp/dist/ClientHttp.jar differ diff --git a/ClientHttp/dist/README.TXT b/ClientHttp/dist/README.TXT new file mode 100644 index 0000000..d6e6245 --- /dev/null +++ b/ClientHttp/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 "ClientHttp.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/ClientHttp/file_ricevuto.unk b/ClientHttp/file_ricevuto.unk new file mode 100644 index 0000000..e69de29 diff --git a/ClientHttp/file_ricevutounk b/ClientHttp/file_ricevutounk new file mode 100644 index 0000000..e69de29 diff --git a/ClientHttp/manifest.mf b/ClientHttp/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/ClientHttp/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/ClientHttp/nbproject/build-impl.xml b/ClientHttp/nbproject/build-impl.xml new file mode 100644 index 0000000..8f9f925 --- /dev/null +++ b/ClientHttp/nbproject/build-impl.xml @@ -0,0 +1,1771 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ClientHttp/nbproject/genfiles.properties b/ClientHttp/nbproject/genfiles.properties new file mode 100644 index 0000000..ca5ae0e --- /dev/null +++ b/ClientHttp/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=1af6744b +build.xml.script.CRC32=402de942 +build.xml.stylesheet.CRC32=f85dc8f2@1.105.0.48 +# 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=1af6744b +nbproject/build-impl.xml.script.CRC32=a7574805 +nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.105.0.48 diff --git a/ClientHttp/nbproject/private/private.properties b/ClientHttp/nbproject/private/private.properties new file mode 100644 index 0000000..1a2f6d1 --- /dev/null +++ b/ClientHttp/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=/home/docente/.netbeans/16/build.properties diff --git a/ClientHttp/nbproject/private/private.xml b/ClientHttp/nbproject/private/private.xml new file mode 100644 index 0000000..e991444 --- /dev/null +++ b/ClientHttp/nbproject/private/private.xml @@ -0,0 +1,9 @@ + + + + + + file:/home/docente/Progetti/ClientHttp/src/clienthttp/ClientHttp.java + + + diff --git a/ClientHttp/nbproject/project.properties b/ClientHttp/nbproject/project.properties new file mode 100644 index 0000000..91e7167 --- /dev/null +++ b/ClientHttp/nbproject/project.properties @@ -0,0 +1,95 @@ +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.modulepath=\ + ${run.modulepath} +debug.test.classpath=\ + ${run.test.classpath} +debug.test.modulepath=\ + ${run.test.modulepath} +# 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}/ClientHttp.jar +dist.javadoc.dir=${dist.dir}/javadoc +dist.jlink.dir=${dist.dir}/jlink +dist.jlink.output=${dist.jlink.dir}/ClientHttp +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.modulepath= +javac.processormodulepath= +javac.processorpath=\ + ${javac.classpath} +javac.source=17 +javac.target=17 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.modulepath=\ + ${javac.modulepath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.html5=false +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +# The jlink additional root modules to resolve +jlink.additionalmodules= +# The jlink additional command line parameters +jlink.additionalparam= +jlink.launcher=true +jlink.launcher.name=ClientHttp +main.class=clienthttp.ClientHttp +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.modulepath=\ + ${javac.modulepath} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +run.test.modulepath=\ + ${javac.test.modulepath} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/ClientHttp/nbproject/project.xml b/ClientHttp/nbproject/project.xml new file mode 100644 index 0000000..e605923 --- /dev/null +++ b/ClientHttp/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + ClientHttp + + + + + + + + + diff --git a/ClientHttp/src/clienthttp/ClientHttp.java b/ClientHttp/src/clienthttp/ClientHttp.java new file mode 100644 index 0000000..f22738a --- /dev/null +++ b/ClientHttp/src/clienthttp/ClientHttp.java @@ -0,0 +1,65 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package clienthttp; + +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class ClientHttp { + + private static String sitoUrl = "http://server.mirimatcode.eu/file"; + private static URL risorsa; + private static HttpURLConnection connessione; + + public static void main(String[] args) { + try { + /* + Download di un file mediante richiesta HTTP, se il file รจ un txt stampa a video il contenuto + altrimenti crea una copia del file in locale + */ + System.out.println("Mi appresto a scaricare il file di testo"); + risorsa = new URL(sitoUrl); + + connessione = (HttpURLConnection) risorsa.openConnection(); + + String content = connessione.getContentType() == null ? "application/unk" : connessione.getContentType(); + + System.out.println("Valore " + content); + + //System.out.println("Content type restituito: " + content + "\n" + " Oggetto restituito: " + connessione.getContent().getClass().getName()); + + if(content.equals("text/plain")) { + BufferedReader buf = new BufferedReader(new InputStreamReader((InputStream) connessione.getContent())); + System.out.println("Frase: " + buf.readLine()); + buf.close(); + } else { + String estensione = content.split("/")[1]; + FileOutputStream streamFile = new FileOutputStream("file_ricevuto." + estensione); + + System.out.println("Estensione: " + estensione); + + streamFile.write(((InputStream) connessione.getContent()).readAllBytes()); + streamFile.flush(); + streamFile.close(); + } + } catch (MalformedURLException ex) { + System.out.println("Errore Malformed: " + ex.getMessage()); + } catch (FileNotFoundException ex) { + System.out.println("Errore FileNotFound: " + ex.getMessage()); + } catch (IOException ex) { + System.out.println("Errore IO: " + ex.getMessage()); + } + } + +} diff --git a/ClientSconnesso/nbproject/private/private.xml b/ClientSconnesso/nbproject/private/private.xml index fd9e0a5..6807a2b 100644 --- a/ClientSconnesso/nbproject/private/private.xml +++ b/ClientSconnesso/nbproject/private/private.xml @@ -2,8 +2,6 @@ - - file:/home/docente/Progetti/Didattica_Socket/ClientSconnesso/src/clientsconnesso/ClientSconnesso.java - + diff --git a/USocket/nbproject/private/private.xml b/USocket/nbproject/private/private.xml index a18b1a5..6807a2b 100644 --- a/USocket/nbproject/private/private.xml +++ b/USocket/nbproject/private/private.xml @@ -2,8 +2,6 @@ - - file:/home/docente/Progetti/Didattica_Socket/USocket/src/com/mirimatcode/UDatagram.java - +