• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

JApplet

Am anfang

Neues Mitglied
Hallo ich habe ein Applet
welches ein Ticker mit Laufschrift erzeugt nun möchte ich die Inhalte ändern
mit einer Variablen die aus eiener .txt liest
hat jemand eine IDEE wäre super
Gruß
SOS
 
PHP:
import java.applet.Applet;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * @author Brebsaron
 */
public class test extends Applet
{
    public void init() 
    {
        /**
         * Hier kannst Du Deine Komponenten initiallisieren.
         * Oder was auch immer ;-)
         */
        
        /**Hier musst Du den Pfad und den Namen Deines Dokumentes eingeben.**/
        String text = readfile("Pfad");
        System.out.println(text);
    }
    /**
     * Diese Methode liefert den Text des im Parameter angegebenem Dokuments zurück.
     * @return Text des Dokumentes
     * @param String Pfad 
     * @author Brebsaron
     */
    public String readfile(String Pfad)
    {
        String Text        = "";
        int CharInInt    = 0;
        char Char        = 0;
        File file         = new File(Pfad);
        if(!file.exists())
        {
            try 
            {
                file.createNewFile();
            }
            catch (IOException e) 
            {
                e.printStackTrace();
                Text = "Fehler: "+e.toString();
            }
        }
        try 
        {
            FileReader read  = new FileReader(file);
            
            while((CharInInt = read.read()) != -1) 
            {
                Char = (char)CharInInt;    
                Text += Char;
            }
        } 
        catch (FileNotFoundException e)
        {
            e.printStackTrace();
            Text = "Fehler: "+e.toString();
        }
        catch (IOException e) 
        {
            e.printStackTrace();
            Text = "Fehler: "+e.toString();

        }
        return Text;
    }
}
 
Zurück
Oben