• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

read text file in java  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, any way to copy a file text content to a text area in JAVA??? please help
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
example:


 
ilham blanchete
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
would  you like to share the full code i am new to java , i am using eclips thank you a lot
 
Saloon Keeper
Posts: 5413
143
Android Firefox Browser Mac OS X Safari Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not how this site works - we don't do all the work for you, but we will help you get there by yourself. So: what do you have so far, and where are you stuck making progress?
 
ilham blanchete
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK!!!
i am trying now to execute the code , i am facing some errors
i am trying to read text file and show it up in a text area , i am gonna try first to brows the file content in console , then open jtextarea to see how i can move the data to it
 
Sheriff
Posts: 5931
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What errors are you getting?  What is the full error message?

Getting your class to print a text file to the console first is a good strategy.  Would you like to post what you have so far?
 
Marshal
Posts: 64179
215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

joseph hu wrote:example: . . .

I am not happy with the example you showed. You are using legacy code and using code at much too low a level. The classes you are using are not ideal for a text file.
 
Sheriff
Posts: 24380
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And building a copy of the entire file in memory as a StringBuilder isn't ideal either. I'm sure that JTextArea must have a method named append() or something like that.
 
Campbell Ritchie
Marshal
Posts: 64179
215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:. . . . I'm sure that JTextArea must have a method named append() or something like that.

I couldn't find it.
 
Sheriff
Posts: 21719
102
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:

Paul Clapham wrote:. . . . I'm sure that JTextArea must have a method named append() or something like that.

I couldn't find it.


https://docs.oracle.com/en/java/javase/12/docs/api/java.desktop/javax/swing/JTextArea.html#append(java.lang.String)
 
Campbell Ritchie
Marshal
Posts: 64179
215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I missed that method the first time I looked. Sorry
 
Talk sense to a fool and he calls you foolish. -Euripides A foolish tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!