-
Re: Question: How do I read info into a java application from a file (txt) and through regular args
"shalom cohen" <c_shalom@hotmail.com> wrote:
>
>Hello,
>I am new to java and have a question.
>Question: How do I read info into a java application from a
> file (txt) and through regular args in javac line?
>Thanks
>Shalom C
Hi Shalom,
Pass the file name as a command line argument. Use the BufferedReader class
to read the text file in your program:
FileInputStream istream = new FileInputStream(args[0]);
BufferedReader reader = new BufferedReader(istream);
String line;
while((line = reader.readLine()) != null)
{
// whatever you want to do with the text
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks