text to table program

 

file name:Texttable.java



import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
class Text_To_Table extends JFrame
{
public void convertTexttotable()
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400,300);
GridLayout g = new GridLayout(0, 4);
setLayout(g);
try
{
FileInputStream fis = new FileInputStream("./Table.txt");
Scanner sc = new Scanner(fis);
String[] arrayList;
String str;
while (sc.hasNextLine())
{
 str = sc.nextLine();
 arrayList = str.split(",");
 for (String i : arrayList)
                {
                    add(new Label(i));
                }
            }
        }
 catch (Exception ex) {
ex.printStackTrace();
        }
        setVisible(true);
        setTitle("Display Data in Table");
    }
}
public class Texttable
{
public static void main(String[] args)
    {
        Text_To_Table tt = new Text_To_Table();
        tt.convertTexttotable();
    }
}








their is another file is attached to the above problem 

file name :Table.txt




NAME,NUMBER,MARKS,RESULT
NAVEEN,501,544,PASS
RAMESH,503,344,PASS
DURGA,521,344,PASS
ASHOK,532,344,PASS
MADHU,543,344,PASS


Comments

Popular posts from this blog

SINGLE LINKED LIST by smd

CLL by smd

QUEUE USING ARRAYS by smd