You are on page 1of 1

1.

Read all Texte in TextBox



import java.io.*;
class Test1 {
public static void main (String [] arg){
JTextBox botext = new JTextBox() ;
File f = new File("Test.txt");
try {
FileReader fr = new FileReader(f);
BufferedReader br = new BufferedReader(fr);
String c ;
while((c =br.readLine())!=null){
botext.setTexte (c);
}
br.close();
}
catch(IOException i){
System.out.print("Error");
}
}
}
2. 2
eme
Methode
import java.io.*;
class FileRead
{
public static void main(String args[])
{
try{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream("textfile.txt");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.println (strLine);
}
//Close the input stream
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
}
Mohlaid0892@hotmail.com

You might also like