String deprecation

I have a warning when compiling a jdk1.1 file under j2sdk1.4
the String(byte[],int)has been deprecated and I didn't understand how to change the instruction using string constructors as it is said in the note in the documentation.
please tell me how.
thanks

If you look at the Documentation for String:
http://java.sun.com/j2se/1.4.1/docs/api/java/lang/String.html#constructor_summary
It says:
String(byte[] ascii, int hibyte)
Deprecated. This method does not properly convert bytes into characters. As of JDK 1.1, the preferred way to do this is via the String constructors that take a charset name or that use the platform's default charset.
And here is that constructor
String(byte[] bytes, String charsetName)
Constructs a new String by decoding the specified array of bytes using the specified charset.
You can start with this "ISO-8859-1" as charsetName, then look here is you want something different.
http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc

Similar Messages

  • Delete charaters from a string

    hi friends
    i want to delete all the charaters after ".". for example 200.00 to 200
    Regards

    I'd write this differenly now, but here's my old String utilities class...
    package krc.utilz;
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;
    import java.util.List;
    import java.util.ArrayList;
    * Some handy String manipulation methods
    public abstract class Stringz {
       * returns the given string with the characters in the opposite order.
       * @param string String - the string to reverse.
       * @return String backwards.
      public static String reverse(String string) {
        return new StringBuffer(string).reverse().toString();
       * Returns the given string with the first letter in uppercase. Note that
       * the case of the rest of the characters in the string remains unchanged.
      public static String capitalise(String string) {
        return string.substring(0,1).toUpperCase() + string.substring(1);
       * returns a string of howMany spaces, or optionally a string of howMany ch's
      public static String spaces(int howMany) {
        return spaces(howMany, ' ');
      public static String spaces(int howMany, char ch) {
        if (howMany <= 0) return "";
        char[] chars = new char[howMany];
        for(int i=0; i<howMany; i++) chars=ch;
    return new String(chars);
    * right pad string to width
    * @param string String = the string to pad
    * @param width int = the desired width of the string
    * @return String the right-padded string.
    * @deprecated - just use String.format("%-${width}s", string);
    @Deprecated
    public static String padRight(String string, int width) {
    return String.format("%-"+width+"s", string);
    //return string + spaces(width - string.length());
    * left pad string to width
    * @param string String = the string to pad
    * @param width int = the desired width of the string
    * @return String the left-padded string.
    * @deprecated - just use String.format("%${width}s", string);
    @Deprecated
    public static String padLeft(String string, int width) {
    return String.format("%"+width+"s", string);
    //return spaces(width - string.length()) + string;
    * find the first token in a string starting at start. think strpbrk.
    * For example<code>
    * String xml = "<tag attr="value">content</tag>"
    * int x = firstOf(xml, " >");
    * System.out.println(x>0 ? s.substring(1,x) : "UNKNOWN");
    * </code>
    * Produces:<code>tag</code>
    * @param string String = the string to search
    * @param tokens String = a logical array of chars to seek
    * @param OPTIONAL start int = start searching string here
    * @return the index of the fist occurence in string of the first found
    * char in tokens, else (no tokens where found) returns -1;
    public static int firstOf(String string, String tokens) {
    for(int i=0; i<string.length(); i++) {
    char ch = string.charAt(i);
    for(char token : tokens.toCharArray()) {
    if (ch==token) return i;
    return -1;
    public static int firstOf(String string, String tokens, int startIndex) {
    return Stringz.firstOf(string.substring(startIndex), tokens);
    * Returns the prefix of the given string which proceeds the first occurrence
    * of any of the given tokens... optionally starting at the given startIndex.
    * <p>
    * For example<code>
    * System.out.println(substring("<tag attr=\"value\">content</tag>", "< >"));
    * </code>produces<code>tag</code>.
    * @param string String - the string to search
    * @param tokens String - a list of chars which serve as end markers
    * @param start int - OPTIONAL start searching string here, 0 based.
    * @return String string[start..token-1], else the empty string
    public static String prefixOf(String string, String tokens) {
    int end = Stringz.firstOf(string, tokens);
    return end==-1 ? "" : string.substring(0,end);
    public static String prefixOf(String string, String tokens, int startIndex) {
    return(Stringz.prefixOf(string.substring(startIndex), tokens));
    * Splits the given string into chunks of the given size.
    * @param string String - The string to split up.
    * @param size it - The size of each chunk.
    public static String[] chunk(String string, int size) {
    Pattern pattern = Pattern.compile(".{1," + size + "}");
    Matcher matcher = pattern.matcher(string);
    List<String> result = new ArrayList<String>();
    while ( matcher.find() ) {
    result.add(matcher.group());
    return result.toArray(new String[result.size()]);
    Edited by: corlettk on 3/08/2008 10:54 - gave up chasing dependencies - just post the whole class.

  • Logic App does not get Swagger Data from API App

    I'm following the tutorial here: http://azure.microsoft.com/en-us/documentation/articles/app-service-dotnet-deploy-api-app/
    I successfully added the API app, but when I add it to a Logic App, it gives the error: "Error fetching swagger api definition. Please try again."
    What is going on? I know the swagger is working properly, because I'm able to consume it from the API app.
    Thanks,

    I have the same issue. Those links don't help and you really have not answered the question.
    I'm using the basic WebApi service that is created by visual studio (plain vanilla string inputs/outputs for all the Http Verbs). The swagger works correctly, but when I deploy to my logic app I get:
    If I browse to the Api App itself I can see the swagger definitions working correctly but there is indeed a red validation warning. If I click the link, however, the validator returns Http 500 Internal Server Error.
    There is some talk on stackoverflow that this is to do with the https certificate that MS is using, and sure enough, if I download the swagger output from the Api App and upload it to a plain http url on another site, it validates correctly.
    So: this seems insoluble. The swagger is correct, but is failing validation, and the Api App cannot be consumed by the logic app.
    Here is the Api App endpoint showing the error: https://microsoft-apiapp4b8b7674e41e4a8f905a2d8b1e4a745b.azurewebsites.net/swagger/ui/index
    And here is the swagger from https://microsoft-apiapp4b8b7674e41e4a8f905a2d8b1e4a745b.azurewebsites.net:443/swagger/docs/v1 
    {"swagger":"2.0","info":{"version":"v1","title":"PE-Services-Idml"},"host":"microsoft-apiapp4b8b7674e41e4a8f905a2d8b1e4a745b.azurewebsites.net:443","schemes":["https"],"paths":{"/api/ToEpl":{"get":{"tags":["ToEpl"],"operationId":"ToEpl_Get","consumes":[],"produces":["application/json","text/json","application/xml","text/xml"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"string"}}}},"deprecated":false},"post":{"tags":["ToEpl"],"operationId":"ToEpl_Post","consumes":["application/json","text/json","application/xml","text/xml","application/x-www-form-urlencoded"],"produces":[],"parameters":[{"name":"value","in":"body","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"No
    Content"}},"deprecated":false}},"/api/ToEpl/{id}":{"get":{"tags":["ToEpl"],"operationId":"ToEpl_Get","consumes":[],"produces":["application/json","text/json","application/xml","text/xml"],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"}],"responses":{"200":{"description":"OK","schema":{"type":"string"}}},"deprecated":false},"put":{"tags":["ToEpl"],"operationId":"ToEpl_Put","consumes":["application/json","text/json","application/xml","text/xml","application/x-www-form-urlencoded"],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"},{"name":"value","in":"body","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"No
    Content"}},"deprecated":false},"delete":{"tags":["ToEpl"],"operationId":"ToEpl_Delete","consumes":[],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"}],"responses":{"204":{"description":"No
    Content"}},"deprecated":false}}},"definitions":{}}

  • Error in 8 that wasent there in 5

    I have a bit a code that used to work in 5 that will not work
    in 8. The script looks like so:
    on (release) {
    _root.gotoAndPlay("Scene_", add
    String(this_scene_number-1));
    The errors im getting are:
    **Error** Scene=Scene 1, layer=back button, frame=1:Line 2:
    ')' or ',' expected
    _root.gotoAndPlay("Scene_", add
    String(this_scene_number-1));
    **Error** Scene=Scene 1, layer=back button, frame=1:Line 3:
    Unexpected '}' encountered
    Total ActionScript Errors: 2 Reported Errors: 2
    Any help is appreciated.
    Thanks,
    Stephen

    add (concatenation (strings))
    Deprecated since Flash Player 5. Macromedia recommends that
    you use the
    add (+) operator when creating content for Flash Player 5 or
    later. This
    operator is not supported in Flash Player 8 or later.
    thanks
    stelios
    "turnerpro1" <[email protected]> wrote in
    message
    news:e7birq$h6l$[email protected]..
    > I have a bit a code that used to work in 5 that will not
    work in 8. The
    script
    > looks like so:
    >
    > on (release) {
    > _root.gotoAndPlay("Scene_", add
    String(this_scene_number-1));
    > }
    >
    > The errors im getting are:
    >
    > **Error** Scene=Scene 1, layer=back button, frame=1:Line
    2: ')' or ','
    expected
    > _root.gotoAndPlay("Scene_", add
    String(this_scene_number-1));
    >
    > **Error** Scene=Scene 1, layer=back button, frame=1:Line
    3: Unexpected
    > encountered
    > }
    >
    > Total ActionScript Errors: 2 Reported Errors: 2
    >
    > Any help is appreciated.
    > Thanks,
    > Stephen
    >

  • Warning [deprecation] setStatus(int,javax.lang.String)

    warning [deprecation] setStatus(int,javax.lang.String) in HttpServletResponseWrapper
    can I find a jee.jar to remplace j2ee.jar to take the resolution of this problem

    The resolution of this problem isn't to fiddle about with .jar files, but to change the code to call the method now recommended instead of the deprecated method. Or just ignore the warning - the code will still work.
    BTW surely it's java.lang.String?

  • Date contructor deprecation : Parsing a String to Date

    Hi All,
    In Java 1.5 the Date() constructor Date(String s) is deprecated. As per the API Documentation DateFormat.Parse() method is used.
    The following code from Java 1.4 version has to be upgraded to Java 1.5.
    Existing Code:
    Date dDate = new Date(sDate);
    Modified Code:
    DateFormat df = DateFormat.getDateInstance();
    Date dDate = df.parse(sDate);
    Here the DateFormat accepts a default formatting style as "Feb 01, 2007" and parses the String.
    If the String sDate belongs to any other formatting style such as "01 Feb, 2007" or "01 Feb, 07" the code piece throws unparsable date error.
    Please give your thougts on this issue to parse the string of any format..
    Thanks,
    Rajesh.

    Hi All,
    In Java 1.5 the Date() constructor Date(String s) is
    deprecated. As per the API Documentation
    DateFormat.Parse() method is used.
    The following code from Java 1.4 version has to be
    upgraded to Java 1.5.
    Existing Code:
    Date dDate = new Date(sDate);
    Modified Code:
    DateFormat df = DateFormat.getDateInstance();
    Date dDate = df.parse(sDate);
    Here the DateFormat accepts a default formatting
    style as "Feb 01, 2007" and parses the String.
    If the String sDate belongs to any other formatting
    style such as "01 Feb, 2007" or "01 Feb, 07" the code
    piece throws unparsable date error.
    Please give your thougts on this issue to parse the
    string of any format..You can't. What date is this: "08/04/24"? 8 April, 1924? 4 August, 2024?
    >
    Thanks,
    Rajesh.

  • Deprecated conversion from string constant to 'char*'

    Hi all
    I am working with strings and i cant figure out why the following
    warning appears at time of build.
    warning: deprecated conversion from string constant to 'char*'
    It appears for the line
    char *myName = "Apple.txt";
    Is there anyone who can help me?
    Help is welcome.
    Thanks in advance.

    Any reason why you aren't using NSString in place of char?
    char *myName = "Apple.txt";
    NSString *myName = @"Apple.txt";

  • Error SQL70015: Error validating element [dbo].[GetDocument]: Deprecated feature 'String literals as column aliases' is not supported

    Using MS SQL Management Studio 2012 attempting to export (from GoDaddy) a .bacpac database for import to Azure and get the error message listed in the Title (String literals as column aliases is not supported on SQL Azure). There was a discussion of this
    problem in mid-2013, but it ended with saying that this was a bug with Azure validation, but had been fixed and did not require rewriting of databases. Anyone with a clue how to successfully export/import around this?

    Hello,
    A string enclosed in quotation marks used as a column alias for an expression in a SELECT list is not support in Windows Azure SQL database. Please use "expression [AS] column_alias" instead of " 'string_alias' = expression ".
    In your case, you can try to create an application with in SSDT and use Schema Compare to filter out and fixed incompatible objects, and then deploy the database to Windows Azure SQL database.
    Reference:
    Use SQL Server Data Tools to Migrate a Database to Azure SQL Database
    Migrating a Database to SQL Azure using SSDT
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • Xmltype.getnumberval() Returns "0" when attribute is an empty string.

    Hi,
    At my workplace we have noticed that when retrieving the value of a numeric attribute of an XML element we are getting "0" when the attribute's value is an empty string (see below for an example script).
    We can't find a reference to this in the documentation but I assume this is expected behavior. Has anyone else experienced this and has anyone else used an alternative work around to the following solution that we are using (with the understanding that it is a third party that is sending us the XML so we cannot just do the sensible thing and make sure the XML doesn't contain attributes with no value)?
    Solution we are using:
    variable := to_number(xml.extract('node()/@numeric_attribute').getstringval());
    Example Script:
    SET serverout ON
    DECLARE
      i xmltype;
    BEGIN
      -- Test statements here
      i := xmltype('<element a="" b="1" c="" d="abc" />');
      -- Get Number Values
      dbms_output.put_line('a=[' || i.extract('node()/@a').getnumberval() || ']*');
      dbms_output.put_line('b=[' || i.extract('node()/@b').getnumberval() || ']');
      -- Get String Values
      dbms_output.put_line('c=[' || i.extract('node()/@c').getstringval() || ']');
      dbms_output.put_line('d=[' || i.extract('node()/@d').getstringval() || ']');
      -- Get String then perform to_number()
       dbms_output.put_line('a (using to_number() on getstringval()=[' || to_number(i.extract('node()/@a').getstringval()) || ']');
      dbms_output.put_line('');
      dbms_output.put_line('*Even though value of attribute in element is an empty string, the getnumberval() function converts this to a 0');
    END;
    Thanks.

    We can't find a reference to this in the documentation but I assume this is expected behavior. Has anyone else experienced this and has anyone else used an alternative work around to the following solution that we are using (with the understanding that it is a third party that is sending us the XML so we cannot just do the sensible thing and make sure the XML doesn't contain attributes with no value)?
    Yes, I remember seeing a thread or two about that in the past.
    Your workaround is probably the best you can come up with if you want to stick to this approach.
    Extractvalue() function works too but it is SQL only.
    However, bear in mind that those functions are deprecated in your version.
    Use XMLQuery to extract scalar values or XMLTable to extract multiple values as relational columns.

  • Deprecation warning for getFontMetrics(java.awt.Font) in java.awt.Toolkit

    Hi all,
    When I use the following code
    JComponent c;
    FontMetrics metrics = getToolkit().getFontMetrics(c.getFont());
    I get this following warning during compilation:-
    warning: getFontMetrics(java.awt.Font) in java.awt.Toolkit has been deprecated
    JDK suggests to use getLineMetrics() of the Font class.
    But there's an issue with that: if I use getLineMetrics(), there is no API method that I can use to get the width of a string as opposed to FontMetrics which provides stringWidth(String str) method for that purpose. In fact all the methods in FontMetrics are not mapped into LineMetrics.
    Could anyone please help or provide me at least some pointers on how to tackle this issue so that I can get rid of the deprecated method along with the existing methods mapped to equivalent APIs? The bottomline is that I should be able to maintain the existing functinality of my application for those part of code that uses getToolkit().getFontMetrics().
    Thank you for your help in advance.
    -Sanjoy Das

    Use Graphics.getFontMetrics(font) instead.
    After creation your frame and calling frame.show();
    You can access it like that
    frame.show();
    frame.getGraphics().getFontMetrics(new Font("Arial",0,10));
    before showing graphics is null.
    Or just create a BufferedImage and ask it for graphics.
    BufferedImage img=new BufferedImage(...);
    img.getGraphics().getFontMetrics(font);
    regards
    Stas

  • Deprecated API and RFC connection issues in PI 7.1

    Hi all,
    I am new to this Forum..
    I am working in File to Proxy scenario where i am using UDF to implemnt few functions.
    But i am getting the following Error :
    Source text of object Message Mapping: MM_FILE_10_943 | urn://fiat.com/mm/if_10_943 has syntax errors:
    Function sendMonitor, Line 14:
    cannot find symbol symbol  : class CallRFCManager location: class com.sap.xi.tf._MM_FILE_10_943_    CallRFCManager rfc=new CallRFCManager();    ^
    Function sendMonitor, Line 14:
    cannot find symbol symbol  : class CallRFCManager location: class com.sap.xi.tf._MM_FILE_10_943_    CallRFCManager rfc=new CallRFCManager();                           ^
    Function sendMonitor, Line 17:
    cannot find symbol symbol  : variable Constants location: class com.sap.xi.tf._MM_FILE_10_943_         if(rfc.connect(Constants.XISYSTEM)){                             ^ Note: /disk2/sap/TX0/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map9c6141de40a611e0ad290000003d38da/source/com/sap/xi/tf/_MM_FILE_10_943_.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: /disk2/sap/TX0/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map9c6141de40a611e0ad290000003d38da/source/com/sap/xi/tf/_MM_FILE_10_943_.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 3 errors
    The code i am using is:
       //write your code here
       // INPUT: activate ; id; descrizione
       AbstractTrace trace;
       String messID;
       java.util.Map map;
       trace = container.getTrace();
       map = container.getTransformationParameters();
       messID = (String) map.get(StreamTransformationConstants.MESSAGE_ID);
       CallRFCManager rfc=new CallRFCManager();
       if (a.equals("true")){
            if(rfc.connect(Constants.XISYSTEM)){     
                  try{
                        rfc.traceMonitor(messID,b,c);
                        trace.addInfo("Ok trace monitor");
                        rfc.disconnect();
                  } catch (Exception ex) {
                        trace.addInfo("Errore in sendMonitor CAUSA:" + ex.getMessage());
                        rfc.disconnect();
            }else{
                      trace.addInfo("Errore in sendMonitor CAUSA: errore sulla connessione ad XI"); 
       return a;
    Pleasae help me ....what is the reason for this ???

    Hi ,
    the package com.fiat.sapiens.udf.* is saved in the IA_JAVA.zip file.
    I imported it in the imported archive and added this jar in the import tab of function library
    i also added ti in the archive used tab in function.
    But still it is showing this Error.
    under IA_JAVA.zip  i have  testJCO.java which has the folowing code:
    package com.fiat.sapiens.xi.udf;
    // Referenced classes of package com.fiat.sapiens.xi.udf:
    //            CallRFCManager
    public class TestJCO
        public TestJCO()
        public static void main(String args[])
            System.setProperty("SAPSYSTEMNAME", "DX0");
            CallRFCManager rfc = new CallRFCManager();
            rfc.connect("XI");
            try
                rfc.schedNR("10", "20", "30", "40", "50", "60");
            catch(Exception e1)
                e1.printStackTrace();
            if(rfc.connect())
                rfc.connect();
                try
                    String a = rfc.checkRARCRE("ZZ");
                    System.out.println(a);
                catch(Exception e)
                    e.printStackTrace();
            System.out.println("");

  • How to read and write a string into a txt.file

    Hi, I am now using BEA Workshop for Weblogic Platform version10. I am using J2EE is my programming language. The problem I encounter is as the above title; how to read and write a string into a txt.file with a specific root directory? Do you have any sample codes to reference?
    I hope someone can answer my question as soon as possible
    Thank you very much.

    Accessing the file system directly from a web app is a bad idea for several reasons. See http://weblogs.java.net/blog/simongbrown/archive/2003/10/file_access_in.html for a great discussion of the topic.
    On Weblogic there seems to be two ways to access files. First, use a File T3 connector from the console. Second, use java.net.URL with the file: protocol. The T3File object has been deprecated and suggests:
    Deprecated in WebLogic Server 6.1. Use java.net.URL.openConnection() instead.
    Edited by: m0smith on Mar 12, 2008 5:18 PM

  • Javax.faces.el.ValueBinding in javax.faces.el has been deprecated

    hi jdev experts,
    am using jdev 11.1.1.5.0 - adfbc-oracledb10g
    my compiler always. please see this warning.
    how can i ignore. may i know the reason of occurence warning. here?
    Warning(4,22):  javax.faces.el.ValueBinding in javax.faces.el has been deprecated
    Warning(922,5):  javax.faces.el.ValueBinding in javax.faces.el has been deprecated
    Warning(922,42):  createValueBinding(java.lang.String) in javax.faces.application.Application has been deprecated
    Warning(989,5):  javax.faces.el.ValueBinding in javax.faces.el has been deprecated
    Warning(989,42):  createValueBinding(java.lang.String) in javax.faces.application.Application has been deprecated
    Warning(1005,5):  javax.faces.el.ValueBinding in javax.faces.el has been deprecated
    Warning(1005,42):  createValueBinding(java.lang.String) in javax.faces.application.Application has been deprecated
    Warning(1020,5):  javax.faces.el.ValueBinding in javax.faces.el has been deprecated
    Warning(1020,42):  createValueBinding(java.lang.String) in javax.faces.application.Application has been deprecated

    A short look into the javadoc reveals javax.faces.el.ValueBinding Deprecated. This has been replaced by ValueExpression.So you are using the wrong class to get to a value using EL inside one or more of your bean classes.
    Timo

  • Warning: [deprecation] getRealPath in ServletRequest has been deprecated

    I have extended class HttpServletRequestWrapper for custom implementation I have neither overriden the method getRealPath(java.lang.String) nor has this method been used/accessed anywhere. I still get following warning
    [javac] /home/pangav1/dev/upgrade/webapps/common/src/minimed/ddms/webapp/common/filter/LocaleFilter.java:222: warning: [deprecation] getRealPath(java.lang.String) in javax.servlet.ServletRequest has been deprecated
    [javac] public static class HttpRequest extends HttpServletRequestWrapper {
    [javac] ^
    Can anyone tell me the reason why compiler shows the warning message?

    It should certainly not be ignored, especially if you don't understand the reason of deprecation and don't know the alternatives, which is the case of the topicstarter. In any case of deprecated classes/methods, the reasoning of deprecation and any alternatives should already be described in the API docs.
    [Here is the API doc of ServletRequest#getRealPath()|http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getRealPath(java.lang.String)]

  • Bogus "deprecated" warnings

    Hi,
    I wrote a class that extends HttpServerResponseWrapper and now I am getting these bogus deprecation warnings:
    warning: [deprecation] setStatus(int,java.lang.String) in javax.servlet.http.HttpServletResponse has been deprecated
    class CacheResponseWrapper extends HttpServletResponseWrapper
    Thing is, I am not overriding or invoking setStatus() at all so what gives? Is this a bug in the javac compiler?
    Gili

    Its not a bug. When implementing an interface, you get this warning if you don't declare the implementation of any deprecated methods declared in the interface as being deprecated in the implementation. HttpServletResponseWrapper doesn't declare its implementation of setStatus(int, String) as deprecated, so this is why you are seeing the warning. If you override the method and mark it as deprecated in your class, the warning will dissappear.

Maybe you are looking for