Datasets:
ArXiv:
License:
Download data/train/AvaN0x/IUT-ProgRep/serveur/src/modeles/Utils.java from RepoFusion/Stack-Repo: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/datasets/RepoFusion/Stack-Repo/resolve/main/data/train/AvaN0x/IUT-ProgRep/serveur/src/modeles/Utils.java
- Command line
-
hf download hf://datasets/RepoFusion/Stack-Repo/data/train/AvaN0x/IUT-ProgRep/serveur/src/modeles/Utils.java
-
curl -L -o Utils.java https://huggingface.co/datasets/RepoFusion/Stack-Repo/resolve/main/data/train/AvaN0x/IUT-ProgRep/serveur/src/modeles/Utils.java
1.01 kB
| package serveur.src.modeles; | |
| import java.io.*; | |
| import java.net.*; | |
| public class Utils { | |
| public static int randomInt(int min, int max) { | |
| return (int) (Math.random() * ((max - min) + 1)) + min; | |
| } | |
| public static String getUrlContents(String theUrl) { | |
| StringBuilder res = new StringBuilder(); | |
| try { | |
| URL url = new URL(theUrl); | |
| // Se connecte à l'URL | |
| URLConnection con = url.openConnection(); | |
| // Récupère le contenu de l'url via des readers | |
| BufferedReader liseur = new BufferedReader(new InputStreamReader(con.getInputStream())); | |
| String ligne; | |
| // Tant que l'url récupérée contient une ligne | |
| while ((ligne = liseur.readLine()) != null) { | |
| // On l'ajoute au résultat | |
| res.append(ligne + "\n"); | |
| } | |
| liseur.close(); | |
| } catch (Exception e) { | |
| e.printStackTrace(); | |
| } | |
| return res.toString(); | |
| } | |
| } | |