• Sábado 21 de Septiembre de 2024, 15:52

Autor Tema:  Archivos En Java  (Leído 986 veces)

Drackzer

  • Miembro activo
  • **
  • Mensajes: 40
  • Nacionalidad: mx
    • Ver Perfil
Archivos En Java
« en: Domingo 7 de Octubre de 2007, 08:14 »
0
Hola Compas de Solo Codigo, ke bueno es regresar por aki..

en fin..

Mi necesidad es, ke no puedo crear un archivo a partir de un texto tecleado en un JextPane..

Lo ke kiero hacer es ke al momento de teclear un texto en el JTextPane, con la accion de un boton, capture ese texto a un archivo nuevo, y despues pasarlo a un archivo que pueda leerlo otro programa denominado prueba2, ke de hecho es un analizador lexico hecho en JFlex...

la cosa esta asi, este es mi codigo:

Código: Text
  1.  
  2. import java.lang.*;
  3. import java.io.*;
  4. import javax.swing.*;
  5.  
  6. public class Archivo
  7. {
  8.   static File file;
  9.   static String codigo;
  10.   private prueba2 pat;
  11.  
  12.  
  13.   public Archivo()
  14.   {
  15.    
  16.   }
  17.  
  18.   public static void saveString(File file, String s)
  19.     throws IOException
  20.     {
  21.         codigo = jTextPane1.getText();
  22.         try
  23.         {
  24.             PrintWriter fileOut = new PrintWriter(new FileWriter(file));
  25.             fileOut.println(codigo);
  26.             fileOut.close();
  27.         }
  28.         catch (IOException ex)
  29.         {
  30.             throw ex;
  31.         }
  32.        
  33.     }
  34.  
  35.     public static void readLines(File file)
  36.     throws FileNotFoundException, IOException {
  37.        
  38.         try
  39.         {
  40.             BufferedReader fileIn = new BufferedReader(
  41.                     new FileReader(file));
  42.  
  43.         }
  44.         catch (FileNotFoundException ex)
  45.         {
  46.             throw ex;
  47.         }
  48.         catch (IOException ex)
  49.         {
  50.             throw ex;
  51.         }
  52.     }
  53.  
  54.  
  55.   public static void main(String args[])
  56.   {
  57.     Archivo obj = new Archivo();
  58.   }
  59. }
  60.  
  61.  
la sentencia : codigo = jTextPane.getText(); es de la interfaz que hice para el analizador lexico que hice
 el pedo es ke no me crea nada, ni me sale nada, si me lee el TextPane, pero no me lee el archivo ke diske se creo, para hacer el analisis.

O uds digan otra solucion para realizar el analisis sin necesidad de esto, y hacerlo directamente del TextPane.

sale compañeros, espero sus respuestas con mucho gusto..

Gracias de antemano
INGENIERIA EN SISTEMAS - Prox. Sitio Web
"BETTA GLOBAL SYSTEMS"