Soldato
- Joined
- 22 Nov 2007
- Posts
- 4,360
Ive got some code that reads from a file and prints it out, but i would like the file to print into a GUI i have. Heres the code for the file reader (if it helps). Can any one help? Thanks
import java.io.*;
// reading text from a file
public class ReadFile {
public static void main(String[] args)
throws IOException {
BufferedReader br = new BufferedReader(
new FileReader ("stockEnquiry1.txt"));
String s;
String name = "";
String phone = "";
String branch = "";
while ((s = br.readLine()) != null) {
if (s.equals("<stock_enquiry>")) {
name = br.readLine();
phone = br.readLine();
branch = br.readLine();
System.out.println("name is " + name + " phone is " + phone + " branch is " + branch);
}
}
br.close();
}
}
import java.io.*;
// reading text from a file
public class ReadFile {
public static void main(String[] args)
throws IOException {
BufferedReader br = new BufferedReader(
new FileReader ("stockEnquiry1.txt"));
String s;
String name = "";
String phone = "";
String branch = "";
while ((s = br.readLine()) != null) {
if (s.equals("<stock_enquiry>")) {
name = br.readLine();
phone = br.readLine();
branch = br.readLine();
System.out.println("name is " + name + " phone is " + phone + " branch is " + branch);
}
}
br.close();
}
}