Converting  String  to  List

I want to convet the String to a List. But I get an error can not cast String to List.
Help???
String str = "Y";
List myList = (List) str;Thanks.

1. Have your String initialized
2. Have your list object
3. Add your string in to the list (LinkedList in this
eg's case)... Easy Pizy!
String str = "a";
LinkedList myList = new LinkedList();
myList.add(str);
So if you want to pass 'str' as a list. Just
use myList. (myList is a list verion of String
'str').
Well, this doesn't change your String into a List, but it creates a List and inserts the String as the first entry there. BIG difference!
Maybe you tell us what you are trying to do, and we tell you how to achieve it.

Similar Messages

  • Converting string to list -- Unknown Operator error

    Dear fellow users,
    in my Authorware project I'm using the following code. On my PC this works FINE, but on any other PC with the same version of Authorware this code results in EvalStatus 4/EvalMessage "Unknown Operator or Illegal character".
    Summary of the code:
    File := ReadExtFile("Test2.txt")
    ClipSections := List(GetLine(File, 1))
    An example of a line in Test2.txt is:
    ["C", "L", "C", "L", "C"]
    The variable File contains: "[\"C\", \"L\", \"C\", \"L\", \"C\"]"
    And the variable ClipSections contains: 0
    I hope someone can help me figure this problem out; I've been trying to solve it (and searching online for relevant help) for hours now!
    Thank you,
    Caspar

    Dear Michael,
    I didn't realize the List Separator was dependent on the language settings. This is indeed the cause of the problem.
    When using the List function, can I specify which separator to use?
    Otherwise I will use something like,
    if ListSeparator <> "," then replace(File, ",", ListSeparator)

  • Converting Arrays to List

    Hi,
    I have the following function that converts String[] to List of int and it's working
    private String putSelect(){
            String msg = SUCCESS;
            try{
                if (session.get("selectCat") != null){               
                    String[] aux = (String[])session.get("selectCat");
                    List aux2 = new ArrayList();
                    for (int i=0;i<aux.length;i++){
                      aux2.add(Integer.parseInt(""+aux));
    setSelectCat(aux2);
    }catch (Exception e) {       
    msg = ERROR;
    System.out.println(e.getMessage());
    return msg;
    but I know that is possible to convert from array to list using :
    Array.asList
    but I need that the resulting list be of int not String, is there a way to modify this setSelectCat(Arrays.asList((String[])session.get("selectCat"))); in order for that to be possible?
    thanks, V

    if you're using java 1.5, then a better loop might be:
    for (String num : aux) {
       aux2.add(Integer.parseInt(num));
    }The variable aux is already a String, so doing "" + aux is pointless. I don't know if a compiler would clean that up for you or not. I'm told that a 'for / in' loop as coded above is marginally faster than an incrementor loop.
    Enjoy!

  • Calling a Web Service in a SSRS Report - Error Converting String to Generic List of Strings

    Hello,
    I am using SSRS version 2005 and am trying to call a web service to retrieve data for a SSRS report.  I've looked on Google and MSDN for the past 2 days and have exhausted all options.  Here are the details...
    The web service method I am calling accepts 4 parameters...
    Parameter 1 = Generic list of strings
    Parameter 2 = DateTime
    Parameter 3 = Int
    Parameter 4 = Int
    I have created a function (on the CODE tab in report properties) in my report that gets passed a comma delimited string and returns a Generic List of Strings that I use to format Parameter 1.  The code for the function is as follows:
    Public Function GetIDs(ByVal IDList as String) As List(Of String)
       Dim stringArray() = IDList.Split(",")
       Dim genericList As New List(Of String)(stringArray)
       Return genericList
    End Function
    I am passing a string to the function that looks something like this:
    "1,2,3,4"
    When I try to PREVIEW the report, I get an error that reads:
    "There is an error on line 0 of custom code: [BC30002] Type 'List' is not defined"
    I've tried changing the function declaration to pass back a string array:
    Public Function GetIDs(ByVal IDList as String) As String()
        Return IDList.Split(","c)
    End Function
    This returned the error (from the web service): 
    "Error in line 5 position 22.  Expecting state 'Element'.. Encountered 'Text' with name ", namespace"
    I have also tried changing the function declaration to pass back an array: 
    Public Function GetIDs(ByVal IDList as String) As ARRAY
    This also produced the error:
    "Error in line 5 position 22.  Expecting state 'Element'.. Encountered 'Text' with name ", namespace"
    I know that this particular web service method DOES work because it is coded to accept nulls in the first parameter.  So... when I call the method with nulls, it returns a recordset of ALL data (this works fine).  Only when I pass a string to the function (which "filters" the recordset by the ID list), does the error occur.
    Is SRSS limited with respect to VB.NET code so that the List(Of String) statement is not recognized?  Has anyone done this before and if so, how did you convert a comma delimited string to a Generic List of Strings within a function in the SSRS report?
    Any info would be greatly appreciated.
    Thanks!
    Bob

    Hi Bob,
    By default, in custom code, in order to use a variable or function that is not in the "System" namespace, we need to provide the full name.
    In this case, the full name of the "List" is "System.Collections.Generic.List"
    So, to solve the issue, please use the following code:
    Public Function GetIDs(ByVal IDList as String) As System.Collections.Generic.List(Of String)
    Dim stringArray() = IDList.Split(",")
    Dim genericList As New System.Collections.Generic.List(Of String)(stringArray)
    Return genericList
    End Function
    If you have any more questions, please feel free to ask.
    Thanks,
    Jin Chen
    Jin Chen - MSFT

  • Converting enumerations to lists with generics

    hello...
    i want to list off system properties and sort them.
    how can you convert enumerations to lists with generics?
    i tried the following in eclipse, but it fails...
         Properties properties = System.getProperties( ) ;
         Enumeration<?> enumeration = properties.propertyNames( ) ;
         ArrayList<String> arrayListEnum = Collections.list( enumeration ) ;
         Collections.sort( arrayListEnum ) ;

    Because the type parameter of Enumeration (<?>) is not compatible with the type parameter of ArrayList (<String>).
    You'll have to do some manual casting yourself.
    Unfortunately, there's nothing to guarantee that system property keys or values are strings (hence why Enumeration<?> and no Enumeration<String>) so you'll need to cope if you find one that isn't.

  • Unable to convert string into binary

    Hello,
    I have a web application that does the following:
    1. Takes in user information via form. This includes images.
    2. Displays all the user information in a portfolio. Looks like the portfolio on this page:
    http://wrapbootstrap.com/preview/WB00PN23G
    3. When clicking on each item you are brought to a page that displays the form information and the images.
    So far it works fine but instead of sending the images as binary to SQL database I send them as strings and the problem is now when I update the code on my cloud host the images no longer display but all the text displays fine. I am thinking the problem
    is that instead of sending my images as strings I need to store them as binary and retrieve them as well. The problem is I did some research and have been unsuccessful in the ways mentioned.
    Here is my code for the form:
    //gather all the information from the form
    //I call a stored procedure to send my data to my sql database
    using (SqlCommand cmd = new SqlCommand("SaveImage", connection.con))
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.Add("@username", SqlDbType.VarChar).Value = UserName.Text;
    cmd.Parameters.Add("@email", SqlDbType.VarChar).Value = Email.Text;
    cmd.Parameters.Add("@project", SqlDbType.NVarChar).Value = Project.Text;
    cmd.Parameters.Add("@description", SqlDbType.NVarChar).Value = Description.Text;
    cmd.Parameters.Add("@img1", SqlDbType.VarBinary).Value = img1;
    cmd.Parameters.Add("@img2", SqlDbType.VarChar).Value = img2;
    cmd.Parameters.Add("@img3", SqlDbType.VarChar).Value = ppt;
    cmd.ExecuteNonQuery();
    cmd.Parameters.Clear();
    connection.con.Close();
    //Here is the stored procedure
    USE [TestDB]
    GO
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER proc [dbo].[SaveImage]
    @username varchar(100),
    @email varchar(50),
    @project nvarchar(MAX),
    @description nvarchar(MAX),
    @img1 varbinary(MAX),
    @img2 nvarchar(MAX),
    @img3 nvarchar(MAX) as
    INSERT INTO ProjectTbl(UserName, Email, ProjectName, ProjectDescription, Image1, Image2, Image3)
    VALUES (@username, @email, @project, @description, @img1, @img2,@img3)
    // Here is the code for the page that displays all the projects submitted in the form of a portfolio (just the backend not the front-end)
    public static string CreateSessionViaJavascript(string strTest)
    Page objp = new Page();
    objp.Session["controlID"] = strTest;
    return strTest;
    public static string imgString;
    //public string[] array;
    public List<string> image1 = new List<string>();
    public List<string> image2 = new List<string>();
    public List<string> image3 = new List<string>();
    public List<string> finalimages = new List<string>();
    protected void Page_Load(object sender, EventArgs e)
    if (!IsPostBack)
    LoadData();
    private void LoadData()
    var data = DataAccess.GetCurrentProject();
    try
    data.Columns.Add("hrefPath");
    foreach (DataRow dr in data.Rows)
    dr["hrefPath"] = "project.aspx?ID=" + dr["Id"];
    DataListProjectImg.DataSource = data;
    DataListProjectImg.DataBind();
    catch (Exception ex)
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    var imgButton = sender as ImageButton;
    if (imgButton != null)
    Response.Redirect("project.aspx?ID=" + imgButton.CommandArgument, false);
    //And here is the code for the each individual item that is clicked on in the portfolio. The images are displayed in a carousel along with the user entered data:
    protected void Page_Load(object sender, EventArgs e)
    //string code = "" + Session["Code"].ToString();
    projectId = Request.QueryString["ID"];
    if (!this.IsPostBack)
    LoadData();
    private void LoadData()
    Connection connection = new Connection();
    try
    connection.connection1();
    SqlCommand com = new SqlCommand("Select Image1,Image2,Image3,UserName,ProjectName,ProjectDescription,Email FROM ProjectTbl Where id='" + projectId + "'", connection.con);
    SqlDataReader dataReader = com.ExecuteReader();
    while (dataReader.Read())
    image1.Src = dataReader["Image1"].ToString();
    image2.Src = dataReader["Image2"].ToString();
    image3.Src = (dataReader["Image3"] != null && (dataReader["Image3"].ToString().Contains(".ppt") || dataReader["Image3"].ToString().Contains(".pptx"))) ? "assets/img/PPTdefault2.png" : dataReader["Image3"].ToString();
    hprPptLink.HRef = (dataReader["Image3"] != null && (dataReader["Image3"].ToString().Contains(".ppt") || dataReader["Image3"].ToString().Contains(".pptx"))) ? dataReader["Image3"].ToString() : "#";
    Name.Text = dataReader["UserName"].ToString();
    ProjectName.Text = dataReader["ProjectName"].ToString();
    Description.Text = dataReader["ProjectDescription"].ToString();
    Email.Text = dataReader["Email"].ToString();
    FillDataForEditProjectModal(dataReader);
    dataReader.Close();
    catch (Exception)
    throw;
    private void FillDataForEditProjectModal(SqlDataReader dataReader)
    UserName.Text = Convert.ToString(dataReader["UserName"]);
    txtEmail.Text = Convert.ToString(dataReader["Email"]);
    Project.Text = Convert.ToString(dataReader["ProjectName"]);
    txtDescription.Text = Convert.ToString(dataReader["ProjectDescription"]);
    protected void btnSaveProjDetails_Click(object sender, EventArgs e)
    SaveUploadedFiles();
    LoadData();
    private void SaveUploadedFiles()
    try
    //validation part
    if (Images1.HasFile)
    if (!CheckImageFileType(Images1))
    GenerateImageUploadJavascriptError("Image 1 Upload");
    return;
    if (Images2.HasFile)
    if (!CheckImageFileType(Images2))
    GenerateImageUploadJavascriptError("Image 2 Upload");
    return;
    if (Images3.HasFile)
    if (!Images3.PostedFile.FileName.ToLower().Contains("ppt") || !Images3.PostedFile.FileName.ToLower().Contains("pptx"))
    string script = "alert('Please Select PPT/pptx type only')";
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "pptUploadError", script, true);
    return;
    //End validation part
    //uploading part
    string image1Path = string.Empty;
    string image2Path = string.Empty;
    string image3Path = string.Empty;
    if (Images1.HasFile)
    image1Path = Path.GetFileName(Images1.PostedFile.FileName);
    Images1.SaveAs(Server.MapPath(image1Path));
    if (Images2.HasFile)
    image2Path = Path.GetFileName(Images2.PostedFile.FileName);
    Images2.SaveAs(Server.MapPath(image2Path));
    if (Images3.HasFile)
    image3Path = Path.GetFileName(Images3.PostedFile.FileName);
    Images3.SaveAs(Server.MapPath(image2Path));
    DataAccess.UpdateProjectDetails(UserName.Text, txtEmail.Text, Project.Text, txtDescription.Text, image1Path, image2Path, image3Path, projectId);
    //end of uplaoding part
    catch (Exception ex)
    throw;
    //Server.Transfer("current.aspx");

    Hi compuluv,
    To store it in the Image object. This image object must be converted to a byte array.
    Based upon your code as below, please try to change Varchar to byte[].
    cmd.Parameters.Add("@img1", SqlDbType.VarBinary).Value = img1;
    cmd.Parameters.Add("@img2", SqlDbType.VarChar).Value = img2;
    cmd.Parameters.Add("@img3", SqlDbType.VarChar).Value = ppt;
    cmd.ExecuteNonQuery();
    For more detailed information, please check
    C# Save and Load Image from Database
    By the way, since your project is a web application, I also found a asp.net version as below.
    You can get some hints.
    http://www.dbtutorials.com/retrieve/saving-retrieving-image-cs/ 
    Best regards,
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Not able to convert string attribute to number and date please help me out

    not able to convert string attribute to number and date attribute. While using string to date conversion it shows result as failure.As I am reading from a text file. please help me out

    Hi,
    You need to provide an example value that's failing and the date formats in the reference data you're using. It's more than likely you don't have the correct format in your ref data.
    regards,
    Nick

  • Convert String to Date and Format the Date Expression in SSRS

    Hi,
    I have a parameter used to select a month and year  string that looks like:    jun-2013
    I can convert it to a date, but what I want to do is,  when a user selects a particular month-year  (let's say "jun-2013")
    I  populate one text box with the date the user selected , and (the challenge Im having is)  I want to populate a text box next to the first text box with the month-year  2 months ahead.    So if the user selects 
    jun-2013   textbox A will show  jun-2013 
    and textbox B will show  aug-2013..
    I have tried:
    =Format(Format(CDate(Parameters!month.Value  ),  
    "MM-YYYY"  )+ 2  )   -- But this gives an error
    This returns the month in number format   like "8"    for august...
    =Format(Format(CDate(Parameters!month.Value  ), 
    "MM"  )+ 2  )
    What is the proper syntax to give me the result    in this format =  "aug-2013"  ???
    Thanks in advance.
    MC
    M Collier

    You can convert a string that represents a date to a date object using the util.scand JavaScript method, and then format a date object to a string representation using the util.printd method. For more information, see:
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1254.html
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1251.html
    In your case, the code would be something like:
    var sDate = "2013-01-10";
    // Convert string to date
    var oDate = util.scand("yyyy-mm-dd", sDate);
    // Convert date to new string
    var sDate2 = util.printd("mm/dd/yyyy", oDate);
    // Set a field value
    getField("date2").value = sDate2;
    The exact code you'd use depends on where you place the script and where you're getting the original date string, but this should get you started.

  • Convert String variable value  to an Object referece type

    Hi all,
    I want to know that if there any possible way to convert String variable value to a Object reference type in java. I'll explain by example if this is not clear.
    Let's think that there is a string variable name like,
    String name="HelloWorld";
    and there is a class name same to the variable value.
    class HelloWorld
    I am passing this string variable value to a method which is going to make a object of helloworld;
    new convertobj().convert("HelloWorld");
    class convertobj{
    public void convert(String name){
    // in hert it is going to create the object of HelloWorld;
    // HelloWorld hello=new HelloWorld(); just like this.
    now i want to do this from the name variable value.( name na=new name()) like wise.
    please let me know if there any possible way to do that.
    I am just passing the name of class by string variable then i wanted to make a instance of the class which come through the variable value.
    thanx.

    Either cast the object to a HelloWorld or use the reflection API (Google it) - with the reflection API you can discover what methods are available.
    Note: if you are planning to pass in various string arguments and instantiate a class which you expect to have a certain method... you should define an interface and have all of your classes that you will call in this way implement the interface (that way you're sure the class has a method of that name). You can then just cast the object to the interface type and call the method.
    John

  • How to convert string to an integer in SQL Server 2008

    Hi All,
    How to convert string to an integer in sql server,
    Input : string str="1,2,3,5"
    Output would be : 1,2,3,5
    Thanks in advance.
    Regards,
    Sunil

    No, you cannot convert to INT and get 1,2,3 BUT you can get
    1
    2
    3
    Is it ok?
    CREATE FUNCTION [dbo].[SplitString]
             @str VARCHAR(MAX)
        RETURNS @ret TABLE (token VARCHAR(MAX))
         AS
         BEGIN
        DECLARE @x XML 
        SET @x = '<t>' + REPLACE(@str, ',', '</t><t>') + '</t>'
        INSERT INTO @ret
            SELECT x.i.value('.', 'VARCHAR(MAX)') AS token
            FROM @x.nodes('//t') x(i)
        RETURN
       END
    ----Usage
    SELECT * FROM SplitString ('1,2,3')
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How to convert String (dd-MMM-yyyy) to oracle.jbo.domain.Date

    Hi
    Could you please tell how do I convert String of date in format dd-MM-yyyy to ADF date? Please show me some sample.
    Thanks

    http://javaalmanac.com/egs/java.text/FormatDateDef.html
    Once you have a java.util.Date you can convert it to oracle.jbo.domain.Date. (see http://www.fifkredit.com/bc4jdoc/rt/oracle/jbo/domain/Date.html)

  • How to convert the alv list data into pdf format

    Hi Expersts,
                      Is it possible to convert the alv list output data into PDF format? if yes, then please help me with this issue.
    thanks in advance,
    Regards,
    Samad

    hii samad,
    you can go through these link.i hope it ll solve your purpose
    How to convert list output to PDF
    Display ALV list output in PDF format
    regards,
    Shweta

  • Facing problem in converting string to date using getOANLSServices()

    I am trying to set a value for date field in my vo and trying to insert into the table.
    In controller I am getting the String which has a date:
    ex: String date="01-NOV-2007";
    while setting into the row I need to convert into Date but it is returning null.
    The below code I used
    to convert into date :
    Date dt = new Date(getOADBTransaction().getOANLSServices().stringToDate(date));
    But this dt is returning a null value is there any solution please advise me.
    Regards!
    Smarajeet

    Smarajeet ,
    See this thread, in one of my replies i have mentioned how to convert string to java.sql.date.You can use the same for oracle.jbo.domain.Date.
    urgent!How to set the default selected date for an OAMessageDateFieldBean
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Converting String To XML Format and send as attachment

    Hi
    My requirement is to convert String into XML Format and that XML File i have to send as an attachment
    can any one one give solution for this Problem.
    Thank you
    Venkatesh.K

    hi,
    i m filling the itab first and converting to xml
    itab contaning these data
    GS_PERSON-CUST_ID   = '3'.
    GS_PERSON-FIRSTNAME = 'Bill'.
    GS_PERSON-LASTNAME  = 'Gates'.
    APPEND GS_PERSON TO GT_PERSON.
    GS_PERSON-CUST_ID   = '4'.
    GS_PERSON-FIRSTNAME = 'Frodo'.
    GS_PERSON-LASTNAME  = 'Baggins'.
    APPEND GS_PERSON TO GT_PERSON.
    after conversion data is coming like that
    #<?xml version="1.0" encoding="utf-16"?>
    <CUSTOMERS>
      <item>
        <customer_id>0003</customer_id>
        <first_name>Bill</first_name>
        <last_name>Gates</last_name>
      </item>
      <item>
        <customer_id>0004</customer_id>
        <first_name>Frodo</first_name>
        <last_name>Baggins</last_name>
      </item>
    </CUSTOMERS>
    but errors are  1) # is coming at the first
                            2)for 'encoding="utf-16"?>', it is not coming perfectly, some other data (iso-8859-1) should come here
    can anybody plz solve it.
    regards,
    viki

  • Converting string to XML format

    Hi All,
    I have a requirement to convert string to xml format and download it. Atpresent, I have a string which is a collection of xml tags. I want to convert this string to xml format like <VALUE004>20387899.437</VALUE004>
    <VALUE005>20387899.437</VALUE005>
    <VALUE006>20387899.437</VALUE006>
    Is there any function module for this.

    Chk this thread.
    Re: Regd: File Conversion to XML format

Maybe you are looking for

  • Entry Parameters in Web Service QUERY_VIEW_DATA

    Hi Gurus, From the entry Prameters of the SAP Standard Web Service QUERY_VIEW_DATA, could you please tell me what for would be the ViewId Parameter? I have always leave it empty and I have not found any example when it appears filled  Thanks so much

  • Cancel Confirmed Quantity in Sales Order Item (VA02)

    Dear All, I am having the following scenario : Customer have created a Sales Order, item 10, schedule line 1 with quantity 120.  The delivery date is 2011.12.22.  They have confirmed the quantity using the "Check Item Availability" function.  They ha

  • Error when running a bat file

    Can someone tell me what this error means; "ORA-12560: TNS:protocol adapter error" I had Oracle XE on my Windows XP Pro SP3, but I also install the EE of Oracle which I haven't setup yet. Originally when I run this .bat file by double clicking on it,

  • Ipod not recognized in itunes. tried a billion things. Can you please help?

    Hey there, Ipod problems... a few weeks ago my ipod died and I managed to restore it over a few days. Seemed to be happy until last night when I plugged it into my computer and ... it didn't work. Windows recognises the ipod. I can see it under MY CO

  • New windows open as Tabs without features

    Hello, When I open a new window of Firefox, it opens as a tab. But with the address bar missing, bookmarks gone, and Back, Forward, Reload not functional. The tab window is below the other toolbars and not at the top of the window. I have to open 3-4