Results 1 to 3 of 3
Thread: text editor does not open file
- 11-21-2010, 06:47 PM #1
Member
- Join Date
- Sep 2010
- Posts
- 61
- Rep Power
- 0
text editor does not open file
My program compiles and runs. But when I try to open a file it does open it
This is the code responsible for opening a file.
Java Code:private void openFile() { try { FileDialog f=new FileDialog(this,"OPEN",FileDialog.LOAD); f.show(); fname=f.getFile(); dir=f.getDirectory(); if(fname==null||dir==null){} else { filename=fname; directory=dir; File fi=new File(directory,filename); FileInputStream fs=new FileInputStream(fi); byte b[]=new byte[fs.available()]; fs.read(b); txtArea.setText(new String(b)); txtArea.append(""); setTitle(filename+" - NOTEPAD"); txtArea.setCaretPosition(0); } } catch(IOException e) { JOptionPane.showMessageDialog(this,"File is not found.Please verify the file name","OPEN",JOptionPane.WARNING_MESSAGE); Open.doClick(); } }
- 11-21-2010, 07:17 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,379
- Blog Entries
- 7
- Rep Power
- 17
- 11-21-2010, 07:39 PM #3
Member
- Join Date
- Sep 2010
- Posts
- 61
- Rep Power
- 0
Similar Threads
-
How correctly open text file?
By artemff in forum CLDC and MIDPReplies: 3Last Post: 12-23-2009, 06:39 PM -
Help for a Text Editor.
By necroninja in forum Advanced JavaReplies: 0Last Post: 08-01-2009, 05:21 PM -
SWT Text Editor Demo
By Java Tip in forum SWTReplies: 0Last Post: 07-11-2008, 04:35 PM -
SWT Text Editor
By Java Tip in forum SWTReplies: 0Last Post: 07-07-2008, 04:43 PM -
Problem in Text Editor
By mustahsan4u in forum New To JavaReplies: 2Last Post: 03-26-2008, 02:34 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks