Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1630 connectés 

  FORUM HardWare.fr
  Programmation
  Java

  [java] ecriture dans un fichier

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[java] ecriture dans un fichier

n°1101156
sam15
Posté le 29-05-2005 à 22:47:24  profilanswer
 

salut tout le monde  
je voulais savoir si c'est possible en  Java d'écrire dans un fichier qui existe déja , je veux dire le modifier  lui ajouter des lignes.....  
import java.io.*;
class AjouterAuFichierTexte{
 
    public static void main(String[] arg) throws IOException{
 
     
    File entree=new File(arg[0]);
        RandomAccessFile ecrivain;
    ecrivain=new RandomAccessFile(entree,write);
     
    ecrivain.writeChars("hanen" );
    ecrivain.close();
 
    }
}
 
 
mais à le compilateur n'aime pas trop le mode "write" dans le constructeur RandomAccessFile.
 
 
2/ est ce qu'on peut passer dans le main un Object?
merci d'avance.
 

mood
Publicité
Posté le 29-05-2005 à 22:47:24  profilanswer
 

n°1101299
Cherrytree
cn=?
Posté le 30-05-2005 à 00:12:27  profilanswer
 

1.

The mode argument specifies the access mode in which the file is to be opened. The permitted values and their meanings are:
 
    Value Meaning
    "r"  Open for reading only. Invoking any of the write methods of the resulting object will cause an IOException to be thrown.
    "rw"  Open for reading and writing. If the file does not already exist then an attempt will be made to create it.
    "rws"  Open for reading and writing, as with "rw", and also require that every update to the file's content or metadata be written synchronously to the underlying storage device.
    "rwd"    Open for reading and writing, as with "rw", and also require that every update to the file's content be written synchronously to the underlying storage device.


 
2. Non

n°1101307
the real m​oins moins
Posté le 30-05-2005 à 00:24:27  profilanswer
 

cherrytree, apprend à lire; le mec là il passe une variable qu'il existe pas; comme il l'a dit c'est "le compilo qui aime pas".
donc avant de lui apprendre à lire la javadoc, faudra lui apprendre à déclarer ses variables.
 
et pour la 2e question, ça serait pas mal aussi d'y dire qu'on voit pas bien par quelle magie ça marcherait [:clappclapp]


Message édité par the real moins moins le 30-05-2005 à 00:24:59

---------------
Hey toi, tu veux acheter des minifigurines Lego, non ?
n°1101467
Cherrytree
cn=?
Posté le 30-05-2005 à 11:51:29  profilanswer
 

the real moins moins a écrit :

cherrytree, apprend à lire

Cordialement.


---------------
Le site de ma maman
n°1101582
the real m​oins moins
Posté le 30-05-2005 à 13:35:39  profilanswer
 

[:nofret]


---------------
Hey toi, tu veux acheter des minifigurines Lego, non ?

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Java

  [java] ecriture dans un fichier

 

Sujets relatifs
Redirection d'un fichier vers un autre[PHP]Recuperer un fichier via son url
projet java bien rémunéréimportation d'un fichier CSV dans une base oracle
Fichier DCU a inclure dans une fiche[Java] écriture dans un fichier
[JAVA] ecriture dans un fichier[JAVA]Pb écriture fichier txt
[JAVA] Ecriture le caractere '\n' au format windows dans un fichier..Comment ouvrir un fichier existant en écriture en Java ?
Plus de sujets relatifs à : [java] ecriture dans un fichier


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR