Solved

DEPRECATED API

Posted on 1998-05-08
7
235 Views
Last Modified: 2010-04-16
if i make this declaration:
StringBufferInputStream cadena=new StringBufferInputStream ("TEXTO A ANALIZAR");

the message is:
the file.java is using a deprecated API

What can i do? I need to analize a String but my program (JLex) has a constructor in which you have to pass an InputStream.
I´ve done this question previously and i´ve been recommend to use a StringBufferInputStream variable, but if i do it the messega is i´m using a deprecated API
0
Comment
Question by:SONIA042198
  • 3
  • 2
  • 2
7 Comments
 

Author Comment

by:SONIA042198
ID: 1220835
Edited text of question
0
 

Author Comment

by:SONIA042198
ID: 1220836
Edited text of question
0
 
LVL 16

Accepted Solution

by:
imladris earned 10 total points
ID: 1220837
SONIA, let's first be clear on what a deprecated API warning means.

A deprecated API is a warning that the class or method used was part of JDK (Java Development Kit) 1.0, that has been superceded by a better class or method. The JDK you are using still supports the superceded class or method, but the deprecation warning indicates that a future JDK may not.

So, if the life of your project is short, or even medium, the warning can safely be ignored. It is only if you are creating production software, something that will have to stay current for years to come, that you need to seriously consider what to do about this.

Your case is complicated by the fact that the LEX package is expecting certain things. The class that supercedes StringBufferInputStream is StringReader. It, however, is not an InputStream. So if you want to use the recommended class, you will have to obtain an updated version of LEX.

0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 6

Expert Comment

by:gadio
ID: 1220838
SONIA, I'm pasting the comment from another Q of your since this comment will help here as well:
-------------------
If you want to get rid of the deprecation warning use:
ByteArrayInputStream cadena=new ByteArrayInputStream((new String("<TXT>TEXTO A
 ANALIZAR</TXT>")).getBytes());
The ByteArrayInputStream is also an input stream and will do for your problem as well. I think that it should remove the deprecation warnings, and will work with the LEX.

0
 

Author Comment

by:SONIA042198
ID: 1220839
If i do that it tells me that class String doesn´t have a method
getBytes()
0
 
LVL 16

Expert Comment

by:imladris
ID: 1220840
Yes, the signature for getBytes is actually:

public void getBytes(int srcBegin,int srcEnd,bytes dst[],int dstBegin);

So it should rewritten to something like:

String ls=new String("<TXT>TEXTO A ANALIZAR</TXT>");
bytes dt[]=new bytes[ls.length()];
ls.getBytes(0,ls.length,dt,0);
ByteArrayInputStream cadena=new ByteArrayInputStream(dt);


0
 
LVL 6

Expert Comment

by:gadio
ID: 1220841
Right, I had a small mistake there.   :-)
The correct version should enable you to work with the javalex.

G.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now