Solved

DEPRECATED API

Posted on 1998-05-08
7
237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Is Applet the way to go for my drag and drop system? 8 51
Selenium docs api java index 3 97
Java 8 to Java 6 8 43
Java array sort 10 62
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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 scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

738 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