import java.io.*; public class Fichier_Exis { public static void main(String args[]) { File f = new File("c:/sakoba.txt"); System.out.println (f + (f.exists()? " existe " : " n'existe pas ")); } }
A voir sur le même Sujet
-
Java: Vérifier si le nom de fichier est accepté par windows
{filelink=12398} public class Fichier_N { /* * Ce programme modifie le nom d’un fichier pour l’adapter à Windows */ public static String adapter_NomFichier(String nom_fichier) { …
-
Attributs des fichiers: Créer un fichier et modifier son attribut.
{filelink=867} import java.io.File; import java.io.IOException; public class AttributFichier { public static void main (String[] args) throws IOException { // Créer un fichier en mode ecriture …
-
Attributs des fichiers: Exemple de Fichier en mode lecture seule.
{filelink=866} import java.io.File; import java.io.IOException; public class FichierModeEcriture { public static void main (String[] args) throws IOException { // Créer un fichier en mode ecriture …
-
Java: Déplacer un fichier
{filelink=7939} import java.io.File; import java.io.IOException; public class Fichier_Depl { /* * Déplacer un fichier d’un répertoire vers un autre */ public static void main(String[] argv) …
-
Java: Créer un fichier
{filelink=7922} import java.io.File; import java.io.IOException; public class Fichier { public static void main(String[] argv) throws Exception { File fichier = new File(“c:/test8.txt”); if (fichier.createNewFile()) System.out.println(“Le …
-
Java: Obtenir le parent d’un fichier
{filelink=7951} import java.io.File; import java.io.IOException; public class Fichier_P { public static void main(String[] argv) throws IOException { File fichier = new File(“c:test2test.txt”); // Obtenir le …
-
Comment Obtenir le lien exacte d’un fichier
{filelink=861} import java.io.*; import java.net.*; public class URLFichier { public static void main(String args[]) throws MalformedURLException { File fichier = new File(“Test”); URL url = …
-
Verifier si un élément existe dans le ‘LinkedList’
{filelink=5192} import java.util.LinkedList; public class LinkedList_Existe { public static void main(String[] args) { LinkedList lk_Liste = new LinkedList(); // Ajout des éléments dans la liste …
-
Exemple d’utilisation des fichiers temporaires en java
{filelink=7971} import java.io.File; import java.io.IOException; public class Fichier_Temp { public static void main(String[] argv) throws IOException { // Créer un fichier temporaire dans le répertoire …
-
Obtenir la taille d’un fichier en octet, en KB et en MB
{filelink=7946} import java.io.File; public class Taille_Fichier { public static void main(String[] args) { File fichier = new File(“D:/fichier.txt”); long taille = fichier.length(); // Taille en …