473,473 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Please help with this Simple compilation error.

2 New Member
When i compile the below program i get the error as:
filereading.java:21: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
while( (record=dis.readLine()) != null )
^
How to get rid of this?


Program :

import java.io.*;

class filereading
{
public static void main (String[] args)
{
FileReadTest f = new FileReadTest();
f.readMyFile();
}
void readMyFile()
{
DataInputStream dis = null;
String record=null;
int recCount = 0;
try
{
File f = new File("name.txt");
FileInputStream fis = new FileInputStream(f);
BufferedInputStream bis = new BufferedInputStream(fis);
dis = new DataInputStream(bis);
while( (record=dis.readLine()) != null )
{
recCount++;
System.out.println ("the names are:" +record);
}
}
catch (IOException e)
{
System.out.println("Unable to copy: "+e.getMessage());
}
}
}
Mar 10 '07 #1
3 1726
r035198x
13,262 MVP
When i compile the below program i get the error as:
filereading.java:21: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
while( (record=dis.readLine()) != null )
^
How to get rid of this?


Program :

import java.io.*;

class filereading
{
public static void main (String[] args)
{
FileReadTest f = new FileReadTest();
f.readMyFile();
}
void readMyFile()
{
DataInputStream dis = null;
String record=null;
int recCount = 0;
try
{
File f = new File("name.txt");
FileInputStream fis = new FileInputStream(f);
BufferedInputStream bis = new BufferedInputStream(fis);
dis = new DataInputStream(bis);
while( (record=dis.readLine()) != null )
{
recCount++;
System.out.println ("the names are:" +record);
}
}
catch (IOException e)
{
System.out.println("Unable to copy: "+e.getMessage());
}
}
}
Do not use Streams to read files. Those methods are deprecated. You should use Scanner or
Expand|Select|Wrap|Line Numbers
  1.  
  2. FileReader fr = new FileReader("fileName.txt");
  3. BufferedReader reader = new BufferedReader(fr); 
  4.  
to read files
Mar 10 '07 #2
MohanaAngamuthu
2 New Member
Do not use Streams to read files. Those methods are deprecated. You should use Scanner or
Expand|Select|Wrap|Line Numbers
  1.  
  2. FileReader fr = new FileReader("fileName.txt");
  3. BufferedReader reader = new BufferedReader(fr); 
  4.  
to read files
Thanks a lot it worked!!!
Mar 10 '07 #3
r035198x
13,262 MVP
Thanks a lot it worked!!!
Anytime. Good luck with the rest of it.
Mar 10 '07 #4

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

Similar topics

4
by: Lloyd Sheen | last post by:
So MS where is the error that is reported on last line, says 1 failed. No indication as to what failed. VS 2003, (reinstalled more times than should have been). ------ Build started: Project:...
4
by: Programmer | last post by:
Hi everyone Well here is my problem I hope you can help me
2
by: Gandu | last post by:
Could a C++ guru help me please? I have a very odd compilation error. The following is the .h file: #ifndef TEST_H #define TEST_H #include <iostream> #include "rando.h" #include "prime.h" ...
2
by: James Zhuo | last post by:
Hi all I've been getting the following compilation error. I should explain the background of the project that i am taking over. This is a project that has been developed by someone else a while...
0
by: James Zhuo | last post by:
Hi all I've been getting the following compilation error. I should explain the background of the project that i am taking over. This is a project that has been developed by someone else a...
3
by: Kris van der Mast | last post by:
Hi, I've created a little site for my sports club. In the root folder there are pages that are viewable by every anonymous user but at a certain subfolder my administration pages should be...
6
by: alban | last post by:
Hello I have got some problems of compilation on a AIX IBM, I use the XLC compilator (And I can't install another one). I try to compile code Pro*c ".pc" (oracle), I need do a pre-compilation...
3
by: seema | last post by:
Hi all, I am new to C programming. I have problem compiling a sample , #include <stdio.h> int getuniqueaddress1(){ return 1; } int getuniqueaddress2(){ return 2;
4
by: Brad Isaacs | last post by:
I am working with ASP.NET 2.0 and using an SQL Server 2000 database. I am using Visual Studio 2005 and developing on my Local machine. I am working with Login controls ASP.Configuration, I...
1
by: zest4 | last post by:
Getting this error, please help what has to be confugured on Win 2003 server? Server Error in '/' Application. -------------------------------------------------------------------------------- ...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.