473,386 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how can I display the contents of a text file?

Pls. teach mo how to display contents of a text file...I still don't know how to utilize BufferedReader and FileReader yet.
Nov 1 '08 #1
4 3794
sukatoa
539 512MB
I think your problem is how to capture the content of a text file,

Here's a sample snippet....

Expand|Select|Wrap|Line Numbers
  1. private byte[] OpenFile(String filepath) throws Exception{
  2.         File file = new File(path);
  3.         FileInputStream read = new FileInputStream(file);
  4.         byte captured[] = new byte[(int)file.length()];        
  5.         read.read(getFile);
  6.         read.close();
  7.         return captured;
  8.     }
try and OBSERVE.....

You can play the returned array of bytes.....
or convert it into String if you're going to display it in swing/awt component
Nov 1 '08 #2
i'm calling a .txt file dude how can i integrate it with gui....thx...
Nov 1 '08 #3
sukatoa
539 512MB
If you use a JTextArea, JTextPane, TextArea, JEditorPane, look for the Java API documentation on the setText method
Nov 1 '08 #4
JosAH
11,448 Expert 8TB
If you use a JTextArea, JTextPane, TextArea, JEditorPane, look for the Java API documentation on the setText method
All these JTextComponents even have a read() method that can read the content
of the component from a text reader.

kind regards,

Jos
Nov 1 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: David Thomas | last post by:
Hi there, a while ago, I posted a question regarding reading japanese text from a text file. Well, since I solved the problem, I thought I'd post my solution for the benefit of other people with...
1
by: - Just Me - | last post by:
It's been 15 years since I did any Basic programming, so I was wondering if I could get some help. I want to display the contents of a .txt file in real-time as the file is updated. I don't want...
4
by: hoke | last post by:
I want to display plain text files in the browser. The files contain html and javascript and have a .txt extension. This works fine with files with just html. Unfortunately when showing files with...
4
by: Ed | last post by:
I am building a glossary. Each letter of the alphabet has its own HTML page, and each glossary entry on the page already has a unique HTML anchor tag immediately to the left of it. I've already...
6
by: Bill Cherepy | last post by:
I don't know if this can be done, but I would like to download and display the contents of a text located on another Web site. I've searched for two days, but have not found any info on this. Help...
6
by: Aspiring .NET Programmer | last post by:
Happy Friday everyone!!! I am working on a windows service and a C# application and needed some help with certain functionality. Please read through my issue below. Thanks! I have a windows...
0
by: cmrhema | last post by:
hello I need to load a file and display the contents in a textbox. I am using asp.net and Visual C# 2005 I tried out this coding string filename = (@"c:\download.txt"); ...
9
by: tshad | last post by:
I have a Windows App that is doing some work and then writing a "Now Processing..." line to the status line of the window as well as the Textbox on the form. But the problem is that the work is...
1
by: iftekar14 | last post by:
i have to create this at VB express 2008 When the user clicks the Process Files button, do the following: Read and process the contents of each of the 6 files. Each file contains data in a...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.