Solved

DEPRECATED API

Posted on 1998-05-08
7
233 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

707 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

13 Experts available now in Live!

Get 1:1 Help Now