CONNEXION
  • RetourJeux
    • Sorties
    • Hit Parade
    • Les + populaires
    • Les + attendus
    • Soluces
    • Tous les Jeux
    • Gaming
  • RetourActu Gaming
    • News
    • Astuces
    • Tests
    • Previews
    • Toute l'actu gaming
  • RetourBons plans
    • Bons plans
    • Bons plans Smartphone
    • Bons plans Hardware
    • Bons plans Image et Son
    • Bons plans Amazon
    • Bons plans Cdiscount
    • Bons plans Decathlon
    • Bons plans Fnac
    • Tous les Bons plans
  • RetourJVTech
    • Actus High-Tech
    • Intelligence Artificielle
    • Smartphones
    • Mobilité urbaine
    • Hardware
    • Image et son
    • Tutoriels
    • Tests produits High-Tech
    • Guides d'achat High-Tech
    • JVTech
  • RetourCulture
    • Actus Culture
    • Culture
  • RetourVidéos
    • A la une
    • Gaming Live
    • Vidéos Tests
    • Vidéos Previews
    • Gameplay
    • Trailers
    • Chroniques
    • Replay Web TV
    • Toutes les vidéos
  • RetourForums
    • Hardware PC
    • PS5
    • Switch 2
    • Xbox Series
    • Switch
    • Pokemon pocket
    • FC 25 Ultimate Team
    • League of Legends
    • Tous les Forums
  • PC
  • PS5
  • Xbox Series
  • Switch 2
  • PS4
  • One
  • Switch
  • iOS
  • Android
  • MMO
  • RPG
  • FPS
En ce moment Genshin Impact Valhalla Breath of the wild Animal Crossing GTA 5 Red dead 2
Liste des sujets

importer une class java

jean-doctrine
jean-doctrine
Niveau 5
22 mars 2018 à 17:36:57

Bonjour,

Je débute en programmation JAVA.

Je voudrais importer une classe qui est dans un fichier texte en .JAVA.

Voici ce qu'il contient :

import java.io.*;
public class Terminal{
static BufferedReader in =
new BufferedReader(new InputStreamReader(System.in));
public static String lireString() // Lire un String
{
String tmp="";
char C='\0';
try {
tmp = in.readLine();
}
catch (IOException e)
{
exceptionHandler(e);
}
return tmp;
} // fin de lireString()
public static int lireInt() // Lire un entier
{
int x=0;
try {
x=Integer.parseInt(lireString());
}
catch (NumberFormatException e) {
exceptionHandler(e);
}
return x ;
}
public static boolean lireBoolean() // Lire un entier
{
boolean b = true;
try {
b = Boolean.valueOf(lireString()).booleanValue();
}
catch (NumberFormatException e) {
exceptionHandler(e);
}
return b;
}
public static double lireDouble() // Lire un double
{
double x=0.0;
try {
x=Double.valueOf(lireString()).doubleValue();
}
catch (NumberFormatException e) {
exceptionHandler(e);
}
return x ;
}
public static char lireChar() // Lire un caractere
{
String tmp=lireString();
if (tmp.length()==0)
return '\n';
else
{
return tmp.charAt(0);
}
}
public static void ecrireString(String s){ // Afficher un String
try{
System.out.print(s);
} catch (Exception ex){
exceptionHandler(ex);
}
}
public static void ecrireStringln(String s) // Afficher un String
{
ecrireString(s);
sautDeLigne();
} // fin de ecrireStringln()
public static void ecrireInt(int i) // Afficher un entier
{
ecrireString(""+i);
}
public static void ecrireIntln(int i) // Afficher un entier
{
ecrireString(""+i);
sautDeLigne();
}
public static void ecrireBoolean(boolean b){
ecrireString(""+b);
}
public static void ecrireBooleanln(boolean b){
ecrireString(""+b);
sautDeLigne();
}
public static void ecrireDouble(double d) // Afficher un double
{
ecrireString(""+d);
}
public static void ecrireDoubleln(double d) // Afficher un double
{
ecrireDouble(d);
sautDeLigne();
}
public static void ecrireChar(char c) // Afficher un caractere
{
ecrireString(""+c);
}
public static void ecrireCharln(char c) // Afficher un caractere
{
ecrireChar(c);
sautDeLigne();
}
public static void sautDeLigne(){
try{
System.out.println();
}catch(Exception ex){
exceptionHandler(ex);
}
}
protected static void exceptionHandler(Exception ex){
TerminalException err = new TerminalException(ex);
throw err;
}
public static void ecrireException(Throwable ex){
ecrireString(ex.toString());
ex.printStackTrace(System.err);
}
}
class TerminalException extends RuntimeException{
Exception ex;
TerminalException(Exception e){
ex = e;
}
}

J'utilise Netbeans et j'aimerai pouvoir utiliser cette classe dans un nouveau project.

Comment faire pour importer cette classe dans mon projet avec NetBeans et comment l'utiliser ?

Merci d'avance.

dechet_s0cial
dechet_s0cial
Niveau 10
22 mars 2018 à 20:08:00

sur netbeans t'ajoute une nouvelle classe
Ctrl C
Ctrl V

cordialement.

Message édité le 22 mars 2018 à 20:08:11 par dechet_s0cial
jean-doctrine
jean-doctrine
Niveau 5
22 mars 2018 à 22:31:14

Directement dans le projet ? si c'est ça j'ai pas vraiment envi de me retrouver avec toutes ces lignes de code.
Sinon utiliser import ? j'ai pas réussi.

Sous forums
  • Aide à l'achat Mac
  • Steam Deck
  • Création de sites web
  • Création de Jeux
  • Linux
  • Programmation
  • Internet
  • Macintosh
  • Hardware
La vidéo du moment