Scanner

i am having a textarea while i click open, filchooser will choose file and then it open it to that particular textarea...

the problem is when i used to open a large file(*.txt) using the below code ..it will display only some last lines...(ignore almost everything)

is there any way to view fuil txt file as i saved...

class OpenListenerimplements ActionListener

{

publicvoid actionPerformed(ActionEvent evt)

{

JFileChooser openchooser =new JFileChooser();

openchooser.setDialogTitle("Open a file...");

int state = openchooser.showOpenDialog(null);

File file = openchooser.getSelectedFile();

if(file !=null && state == JFileChooser.APPROVE_OPTION)

{

Scanner scan =null;

try

{

scan =new Scanner(new BufferedReader(new FileReader(file)));

scan.useDelimiter(",\\s*");

while (scan.hasNext())

{

textarea.setText(scan.next());

}

}

catch(Exception e){e.printStackTrace();}

finally

{

if (scan !=null)

{

scan.close();

}

}

}

elseif(state == JFileChooser.CANCEL_OPTION)

{

return;

}

}

}

[2463 byte] By [Reona] at [2007-11-27 4:09:43]
# 1
textarea.setText(scan.next());Read the javadoc about setText. That replaces the previous text. Call append instead.Kaj
kajbja at 2007-7-12 9:15:12 > top of Java-index,Java Essentials,Java Programming...
# 2
Actually what happened here is ...I tried to open a long (*.java) file...but it works(means not completely as in that file i saved )...but i tried to open a large txt file it works correctly...i didnt understand wats happening there....
Reona at 2007-7-12 9:15:12 > top of Java-index,Java Essentials,Java Programming...