Solved

DEPRECATED API

Posted on 1998-05-08
7
234 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Understanding websocket example in spring 1 56
starter POM and spring-boot-starter,  spring-boot-web 2 43
javap bin 2 27
varialbe initialization 11 30
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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…
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 regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

910 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

19 Experts available now in Live!

Get 1:1 Help Now