From 89c209b9e9367600038fd92009d35e7058a2cbe9 Mon Sep 17 00:00:00 2001 From: mirimatcode Date: Fri, 10 Mar 2023 15:47:15 +0100 Subject: [PATCH] Inserimento codice relativo a java.net URL e HttpUrlConnection --- ClientHttp/build.xml | 73 + ClientHttp/build/built-jar.properties | 4 + .../build/classes/.netbeans_automatic_build | 0 .../build/classes/.netbeans_update_resources | 0 .../build/classes/clienthttp/ClientHttp.class | Bin 0 -> 2994 bytes ClientHttp/dist/ClientHttp.jar | Bin 0 -> 3847 bytes ClientHttp/dist/README.TXT | 32 + ClientHttp/file_ricevuto.unk | 0 ClientHttp/file_ricevutounk | 0 ClientHttp/manifest.mf | 3 + ClientHttp/nbproject/build-impl.xml | 1771 +++++++++++++++++ ClientHttp/nbproject/genfiles.properties | 8 + .../nbproject/private/private.properties | 2 + ClientHttp/nbproject/private/private.xml | 9 + ClientHttp/nbproject/project.properties | 95 + ClientHttp/nbproject/project.xml | 15 + ClientHttp/src/clienthttp/ClientHttp.java | 65 + ClientSconnesso/nbproject/private/private.xml | 4 +- USocket/nbproject/private/private.xml | 4 +- 19 files changed, 2079 insertions(+), 6 deletions(-) create mode 100644 ClientHttp/build.xml create mode 100644 ClientHttp/build/built-jar.properties create mode 100644 ClientHttp/build/classes/.netbeans_automatic_build create mode 100644 ClientHttp/build/classes/.netbeans_update_resources create mode 100644 ClientHttp/build/classes/clienthttp/ClientHttp.class create mode 100644 ClientHttp/dist/ClientHttp.jar create mode 100644 ClientHttp/dist/README.TXT create mode 100644 ClientHttp/file_ricevuto.unk create mode 100644 ClientHttp/file_ricevutounk create mode 100644 ClientHttp/manifest.mf create mode 100644 ClientHttp/nbproject/build-impl.xml create mode 100644 ClientHttp/nbproject/genfiles.properties create mode 100644 ClientHttp/nbproject/private/private.properties create mode 100644 ClientHttp/nbproject/private/private.xml create mode 100644 ClientHttp/nbproject/project.properties create mode 100644 ClientHttp/nbproject/project.xml create mode 100644 ClientHttp/src/clienthttp/ClientHttp.java 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 0000000000000000000000000000000000000000..689215e97c5b6b9c4b4d9bc824fc5a77b92f2095 GIT binary patch literal 2994 zcmZuzX>$}+6g@8_^kiraPCym~1`Lou$S6jX1VIuLh-ASeL?I}4W?qseJ>6q>Pay8% zzT*yx`w|ya2-L(1RTkf@!hc|u{sa91mRg?IJxL~JKJ@GN-aYre+vhH?ulzgp6M)-s zE{YN?&`_$Q3=0JoA2mjegk{)6iLQa8GU*E}++o_Lzf)jAbxmJ6A}H4o)v*Zr9C*)| z=gTxvPL@hb+XF+Uli2T?w%_Bs(nvQ(aJ4{nhZ#3A8CQC~6F1^s(r`^aGHzP&LDQ1) zlo|JxFp9;vMng(6omdYx*=?E1(Cew)7JRy4%aK z94j=e)NviIr&`i7rR@*sX6*RB=tu zaXmxe>QE(rVxxjr=~#~q6ge4bH#@dXa!rSRudJ?_gPxT&YN)1s#(Cu!KVTN14&S6> zGin7EC6!IjqfIGr{jAA(T6AY4>U1P$nBm1eT?Z5lK6g-eda1oO!-s`<}ptVquxjXau(jM16VOPh>2^w4-PM zzki3$BxUXuh5X8UsoY zYj=`{)yEd6*7?m+f7m2P%i4>!o<^EWvjUjC)kPvy)5jh=kR4>0!tgPr=4LkyMA<*3 zo$m!vFX+B1nCvDqO8*Zo)im}H)d>VjB*}?~Sk=XfhJqSv=9rtuHW9NoLE9|F+%GlU zA(Bv8hX=_NQaThGq$)x`om6Yzu_8b=}VW2ksV|&yqKarPS#Dz@B=Gmn|Phd z1on<5$MMO5kqNDM6$|lh6sK@n!+WZKy)RG|Bu&urOncNBk%_R)ge|SrNcxUDCUB~- zjPk(H=w8E4S<GCg(#2hI5en>Ia^71R; z6|?|Rb(3=z<=(pB%^NY0u-~wb1s>%p!MEVMY||vfc}`037)K=r|1cissD}VNfhV~t z#|b<|6qUt4G*rsHKPRBYuF9d}5|$pEz_LlKx_~tkSd+sIm$C5zY9>&V!x8z{*vBt4I@E`|g3T^-$$AU*Y}r3mWk&=f7bG ze&;X1AH3{Tgt~cBlF@n^&oDA4Xz5vozJxZb@Eo3}SKH{<3)~a5SAiGt5@){zvzIyh zJ(#@`#Q9IWiq~lKB%f7?Bw92y{EcRgf1#mCL%Lgo$LClDUMHkX5D%XJ#!O1B4(u?8 zVh>-yGL=)JAg7knn>V>vg17KC-?h;24iRU9@xx&JI2b<-#?OQC%V7Kp-%uk;^tbp9 HKVZdwol6u? literal 0 HcmV?d00001 diff --git a/ClientHttp/dist/ClientHttp.jar b/ClientHttp/dist/ClientHttp.jar new file mode 100644 index 0000000000000000000000000000000000000000..47af1fef5ce4d33afe3c3a98f8117984fbe26526 GIT binary patch literal 3847 zcmZ`+`Ewjc75+wtXEhl`W-Z5di0w&mY{{~ACB^X}IRQyXSXe75x)R$!JlbtZW6jQN zW@crJfP(;YLkMTg6%G?a2n5TpB61a#pIw#w2UI0h{7P~BNTmW_&#rc7t<6f)-Shgr z*WKT{dM3`)H)uc%*jTh?5&1Qt0jZ(s{?3uH;pBUFfQd5e>tr?m`Rd-klU+Woe9Ek; z{;`qap{eOaYB*&&*1Yh8&ROC4mh1Ey-HEPdt>1}I`g3M_Q5d9gvb!sBqFEdCgc*oT z=fDaDjwiYj$2z*ZI%nqcPLS{H%7=Y-PgkPrXrkL_oA9h)v+Z4Gs(SJ9xO5!)1Ozi2L-N!xT5lH+q1MLJNh?UdzM!Q%?*+uCQFXx1hbn$E50 zRqRtMeju{sa`P10IT|Xm+$6Ddf~kP`XZvEfS3z6KGR$1gqY+)hH2k#b5hhOuY&vA+N-!LbA2k>IA7kp^ba1O!XOtvtfK=*6x@@R zI(-=vLcs$Sm0P5^okK|INTQ3|Sr7pg2K2<~l^i8oH@6eTQ9}2Ot+MRhOBVf(o29_QPs_lhDvJPNS#Yc4v$s@IdfQ8#H38|DHGqWO2pZ}PS(-={(D{C$Zo}Bx8(h3$i z@&nTexWtJXjoE~&R!xHvsm_|;= zGw_%TJy{yPEI)^T&MNYcBhG%g_$8!=n>Fy~8r@27v>TyBE=N0UYZhXuQ zhTXiAiHNV_N}L6g%wLKccs#;#RkAeVLJVJ1@USc;y~(66yk+4fvX*DD1f|`KNQit= zrq)C*L(CfnNn)5tOOEBUbHbZ8=WJ5qqb}>!Ec3B^FA*DpMTSxQ-Q{0FPu{1()_SgNLw=Xm4)uMEyYwOJejr>)QQUqj3V#* znu8MitJG~loE(+1HBy0@^aj&gAP75Z98p2@RA8o;Qf97%SnL#`Dwa%b%FTOeQ9Mmc zrMx7h>6u3dTsPo>&0Ir708wCeKFA39((XK=(Do;>T~GsYn>5U`IGSS-@ij^lxAoprVfW#|s#}hVI*# zIC~qD)Jg>>-@x=bX4i2xMZqHld}0Gnhx{DR-9S%AToka-(3852rL#vikOkJ^jCGc! z3vdhYxsgkJK79ix!yOdx*$sRyRCEIeOQbJs;EN^FjuPq18~92{x=DPc>J27e*}sX^ zuzwp@IU@m_#~!wac#m!4t?V#ua0Dljz!T`gIdsEgJzB*hjcnQbx8cyIA zIoB~m?c?D2afjnKDft#F?cX?l8&i0PwdP-#4GlEORXpBazk~16d@tZ2zDLW~QQvNS zA3xxZPT~rFNSZ=@EqD>vIC?7_{fMJ?!qJa8qABqc{FMFA`0PcjXGlfQyBKHtUnB-p zJUgjkmCw}{F8Wg0jrN7Y^qcrsZ(*18BPHTTd$@(4lU9dc;Fs(VQtnse_-)w!E^L1v zwy%Zl&9J?NKa*D@Ujct17<(qpD0Qv%@Bht5ZvM98AN{f~f7TVh04t)kz5%6x{9Rw| zU|SZAd=W+$ml{I$QX{{Yia)t{KXHsyvAYHD{(jmNy}rt;NmMYB$J6pwI&r3Pn`Ca_ M-~ZVEr&+%JA3OE*%m4rY literal 0 HcmV?d00001 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 - +