Results 1 to 5 of 5
Thread: load a text in a view
- 08-17-2010, 11:04 AM #1
Member
- Join Date
- Jul 2010
- Posts
- 8
- Rep Power
- 0
load a text in a view
Hi all
I've added a view to my plugin and in this view I created a text zone .
What I want to do now is to display the content of a file in my text zone . I used a clasic methode : parsing a file and print the content but I have a problem in my code because I didn't manage to have an exact copy of my file : I got the content in only one line !! there is no wrap
here is the code :
please help me find the problem and thanks in advanceJava Code:public void createPartControl(Composite parent) { text = new Text (parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); try { FileInputStream myFile = new FileInputStream("......"); DataInputStream myInput = new DataInputStream (myFile); BufferedReader br = new BufferedReader(new InputStreamReader(myInput)); String line ; StringBuilder builder = new StringBuilder(); while((line = br.readLine()) != null){ builder.append(line).toString() ; } text.setText(builder.append(line).toString()); myInput.close(); } catch (Exception e) { System.err.println("Error: " + e.getMessage()); } }
- 08-17-2010, 11:29 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
StringBuilde didn't append with the line-breaks and all. In what format your file content with you?
- 08-17-2010, 01:07 PM #3
Member
- Join Date
- Jul 2010
- Posts
- 8
- Rep Power
- 0
hello !!
I got the solution :D thanks any way :)
here is the code :
Java Code:while((line = br.readLine()) != null){ builder.append(line); builder.append("\n"); } text.setText(builder.toString());
- 08-17-2010, 01:13 PM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Use system properties to define those values.
Java Code:System.getProperty("line.separator")
- 08-17-2010, 01:57 PM #5
Member
- Join Date
- Jul 2010
- Posts
- 8
- Rep Power
- 0
Similar Threads
-
How enter this mode-gui/design-view/code-view
By lse123 in forum NetBeansReplies: 0Last Post: 02-28-2010, 09:09 PM -
Updating a view using actions in a seperate view
By xcallmejudasx in forum EclipseReplies: 0Last Post: 10-24-2008, 09:24 PM -
map javax.swing.text.Element to javax.swing.text.View
By elizabeth in forum New To JavaReplies: 1Last Post: 07-30-2007, 07:02 PM -
problems trying to view the contents of a text file in JTextArea
By warship in forum New To JavaReplies: 1Last Post: 07-18-2007, 11:20 PM -
problem trying to view the contents of a text file in JTextArea
By warship in forum AWT / SwingReplies: 0Last Post: 07-17-2007, 03:30 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks