Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DEPRECATED API

Posted on 1998-05-08
7
Medium Priority
?
243 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 20 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This video teaches viewers about errors in exception handling.
Suggested Courses

916 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