473,383 Members | 1,818 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,383 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 3793
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.