Typecasting string to integer. need help

Hi,
I have the following statement which returns a String but i need to convert to an integer .
properties.getProperty("MAXWIDTH");
Can i do it this way,
int width = (Integer) properties.getProperty("MAXWIDTH");
But it gives me error stating that it cannot convert string to integer.
Please help
Purnima

That's because the value returned from the
getProperty() method is a String. You can convert it
to an int, like this:int width =
Integer.parseInt(properties.getProperty("MAXWIDTH"));[
/code]oh so simple thanks
Purnima

Similar Messages

  • JDBC:KPRB string size limits-NEED HELP!

    Hello All.
    Please, I need your help.
    I have the problems in Oracle 9.2.0.6 with stored java and jdbc:kprb internal driver.
    I try to put string(more than 32K) into LONG-type field using following java class:
    import oracle.sql.CLOB;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.io.Reader;
    import java.io.CharArrayReader;
    public class LongTest {
    public static void insertLong()
    throws Exception {
    Connection con = DriverManager.getConnection("jdbc:default:connection:");
    //generate large string
    StringBuffer stringBuffer = new StringBuffer();
    for (int i = 0; i < 100000; i++) {
    stringBuffer.append("qwerty");
    String st = stringBuffer.toString();
    //put large string to long-type field
    PreparedStatement pst = null;
    try {
    pst = con.prepareStatement("insert into TEST_LONG (ldata) values (?)");
    pst.setString(1, st);
    pst.execute();
    } finally {
    if (pst != null) {pst.close();}
    But I get error from jdbc:kprb about limitation of data size for this type(LONG).
    But it works well in oracle 10.2.0.1...
    Has anybody a solution of how to do this in oracle 9.2.0.6???
    thanx!

    Hi,
    THis is a known limitation in the 92 RDBMS solved in 10g.
    Kuassi http://db360.blogspot.com

  • Bit char string...need help

    Hi I am trying to convert a bit char string to something useful.  Basically I have an activex tool that allows me acess to a serial port based scale.
    I send a weight request command and it sends me this gibberish:
    °®°° ìb ÇR
    Thank I try to do a tostring() and get this:
    \u00b0\u00ae\u00b0\u00b0, on line 1, column 21, is not a valid identifer name.
    Hmm.. anyone have to deal with bitchar strings coming from serioal ports or know what i am dealing with here?
    Thanks
    Frank

    Basically you need to access the string as a byte array - I think
    there's a method getBytes() that you can apply to a string.
    Mack

  • Need help in the String Format method

    really need help in string.Format method. I would like to show the s in two digit numbers.
    for example:
    if s is below 10 then display *0s*
    the expecting result is 01,02,03.. 09,10,11....
    I tried this method, somehow i got the errors msg. pls advise. thx.
    public void setDisplay(String s) {
    String tmpSS=String.format("%02d",s);
    this.ss.setText(tmpSS);
    Edited by: bluesailormoon on May 19, 2008 10:30 AM

    Apparently, you expect the string to consist of one or two digits. If that's true, you could do this:String tmpSS = (s.length() == 1) ? ("0" + s) : s; or this: String tmpSS = String.format("%02d", Integer.parseInt(s));

  • Logic behind string to integer typecasting..

    hi fourm,
    i'm siva. i learnt typecasting in java. but i'm still wondering how the string to integer typecasting works, what is the logic behind this casting. somebody please help me out...
    Advance thanking
    siva

        public static int parseInt(String s) throws NumberFormatException {
         return parseInt(s,10);
        public static int parseInt(String s, int radix)
              throws NumberFormatException
            if (s == null) {
                throw new NumberFormatException("null");
         if (radix < Character.MIN_RADIX) {
             throw new NumberFormatException("radix " + radix +
                                 " less than Character.MIN_RADIX");
         if (radix > Character.MAX_RADIX) {
             throw new NumberFormatException("radix " + radix +
                                 " greater than Character.MAX_RADIX");
         int result = 0;
         boolean negative = false;
         int i = 0, max = s.length();
         int limit;
         int multmin;
         int digit;
         if (max > 0) {
             if (s.charAt(0) == '-') {
              negative = true;
              limit = Integer.MIN_VALUE;
              i++;
             } else {
              limit = -Integer.MAX_VALUE;
             multmin = limit / radix;
             if (i < max) {
              digit = Character.digit(s.charAt(i++),radix);
              if (digit < 0) {
                  throw NumberFormatException.forInputString(s);
              } else {
                  result = -digit;
             while (i < max) {
              // Accumulating negatively avoids surprises near MAX_VALUE
              digit = Character.digit(s.charAt(i++),radix);
              if (digit < 0) {
                  throw NumberFormatException.forInputString(s);
              if (result < multmin) {
                  throw NumberFormatException.forInputString(s);
              result *= radix;
              if (result < limit + digit) {
                  throw NumberFormatException.forInputString(s);
              result -= digit;
         } else {
             throw NumberFormatException.forInputString(s);
         if (negative) {
             if (i > 1) {
              return result;
             } else {     /* Only got "-" */
              throw NumberFormatException.forInputString(s);
         } else {
             return -result;
        }Now where is the missing "logic".

  • Need Help in Splitting a String Using SQL QUERY

    Hi,
    I need help in splitting a string using a SQL Query:
    String IS:
    AFTER PAINT.ACOUSTICAL.1..9'' MEMBRAIN'I would like to seperate this string into multiple lines using the delimeter .(dot)
    Sample Output should look like:
    SNO       STRING
    1            AFTER PAINT
    2            ACOUSTICAL
    3            1
    4            
    5            9" MEMBRAIN
    {code}
    FYI i am using Oracle 9.2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    There's this as well:
    with x as ( --generating sample data:
               select 'AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN' str from dual union all
               select 'BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN' str from dual)
    select str,
           row_number() over (partition by str order by rownum) s_no,
           cast(dbms_xmlgen.convert(t.column_value.extract('//text()').getstringval(),1) as varchar2(100)) res
    from x,
         table(xmlsequence(xmltype('<x><x>' || replace(str,'.','</x><x>') || '</x></x>').extract('//x/*'))) t;
    STR                                                S_NO RES                                                                                                
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 1 AFTER PAINT                                                                                        
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 2 ACOUSTICAL                                                                                         
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 3 1                                                                                                  
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 4                                                                                                    
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 5 9" MEMBRAIN                                                                                        
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          1 BEFORE PAINT                                                                                       
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          2 ELECTRIC                                                                                           
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          3 2                                                                                                  
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          4                                                                                                    
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          5 45 caliber MEMBRAIN      
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Need help for string tokenizer!

    I need help in writing out the string tokenizer.. i've got all of the functions written except for the nexttokken function which i am stuck in. Can anyone help me out in writing the function?

    An example of splitting string by comma
    String str"A,B,C";
    StringTokenizer st = new StringTokenizer(str,",");
    while (st.hasMoreTokens()) {
    System.out.println(st.nextToken());
    This is just an example of usage; i would prefer to use split() function instead

  • I need help to convert a string to date and time

    Good aft,
    1.How can i get a date from the user input thro' Frames?
    2.How to parse it to the date object(I need to include java.util.Date but for the database i need to include java.sql.*,if i do so, i have error as
    found:java.util.Date
    Required:java.sql.Date)
    3.How to insert into the database
    The same i need help to insert time into database?
    I need solution and explanation...
    Reply me immediately...
    If u send me the code, its better to me.

    Hello,
    The best way is to use the HEX to decimal coversion VI in the string pallette. Then, write this decimal directly to your chart. If you are doing it a point at a time put it into a while loop.
    Doug

  • Need help in laoding flat file data, which has \r at the end of a string

    Hi There,
    Need help in loading flat file data, which has \r at the end of a string.
    I have a flat file with three columns. In the data, at the end of second column it has \r. So because of this the control is going to the beginning of next line. And the rest of the line is loading into the next line.
    Can someone pls help me to remove escape character \r from the data?
    thanks,
    rag

    Have you looked into the sed linux command? here are some details:
    When working with txt files or with the shell in general it is sometimes necessary to replace certain chars in existing files. In that cases sed can come in handy:
    1     sed -i 's/foo/bar/g' FILENAME
    The -i option makes sure that the changes are saved in the new file – in case you are not sure that sed will work as you expect it you should use it without the option but provide an output filename. The s is for search, the foo is the pattern you are searching the file for, bar is the replacement string and the g flag makes sure that all hits on each line are replaced, not just the first one.
    If you have to replace special characters like a dot or a comma, they have to be entered with a backslash to make clear that you mean the chars, not some control command:
    1     sed -i 's/./,/g' *txt
    Sed should be available on every standard installation of any distribution. At lesat on Fedora it is even required by core system parts like udev.
    If this helps, mark as correct or helpful.

  • Still need help with case sensitive strings

    Hello guy! Sorry to trouble you with the same problem again,
    but i still need help!
    "I am trying to create a scrypt that will compare a String
    with an editable text that the user should type to match that
    String. I was able to do that, but the problem is that is not case
    sensitive, even with the adobe help telling me that strings are
    case sensitive. Do you guys know how to make that comparison match
    only if all the field has the right upper and lower case letters?
    on exitframe
    if field "t:texto1" = "Residencial Serra Verde"then
    go to next
    end if
    end
    |----> thats the one Im using!"
    There were 2 replys but both of them didnt work, and the
    second one even made the director crash, corrupting even previously
    files that had nothing to do with the initial problem..
    first solution given --
    If you put each item that you are comparing into a list, it
    magically
    makes it case sensitive. Just put list brackets around each
    item.
    on exitframe
    if [field "t:texto1"] = ["Residencial Serra Verde"] then
    go to next
    end if
    end
    Second solution given--
    The = operator is not case-sensitive when used on strings,
    but the < and > operators are case-sensitive.
    So another way to do this is to check if the string is
    neither greater than nor less than the target string:
    vExpected = "Residencial Serra Verde"
    vInput = field "t:texto 1"
    if vExpected < vInput then
    -- ignore
    else if vExpected > vInput then
    -- ignore
    else
    -- vExpected is a case-sensitive match for vInput
    go next
    end if
    So any new solutions??
    Thanks in advance!!
    joao rsm

    The first solution does in fact work and is probably the most
    efficient way
    of doing it. You can verify that it works by starting with a
    new director
    movie and adding a field named "t:texto1" into the cast with
    the text
    "Residencial Serra Verde" in the field. Next type the
    following command in
    the message window and press Enter
    put [field "t:texto1"] = ["Residencial Serra Verde"]
    You will see it return 1 which means True. Next, make the R
    in the field
    lower case and execute the command in the message window, it
    will return 0
    (true).
    Now that you know this works, you need to dig deeper in your
    code to find
    what the problem is. Any more info you can supply?

  • Need help in String operations

    HI all,
    I need help in String operations.I am getting file path of an image as
    c:\test\img\abc.gif"
    I need to convert it in to c:/test/img/abc.gif".
    Can any one suggest the solution for this.
    Thanks,
    Durga.

    [email protected] wrote:
    I used String replace method but I am not able to do it because "/" is a special character."/" is not a special character, "\" is a special character, which needs to be escaped by "\" itself.

  • (String)myObject vs myObject.toString() -- Needed Help

    Ihave Some thing like
       String myString = Integer.parseInt((String)pageContext.getAttribute("myKey"));In page context I'm storing a reference to my class , but tis line gives me an error. ( Class Cast Exception)
    But,
       String myString = Integer.parseInt(pageContext.getAttribute("myKey").toString()); OR
       String myString = Integer.parseInt(" "+pageContext.getAttribute("myKey")); Will solve the problem, please tell me why ?
    Thanks in adavnce.

    You should try to use the simplest example code you can. Firstly, this
    has nothing to do with Integer.parseInt, which return an int not a String
    anyway, and pageContext isn't important in this example either. It boils down to:
    Object myObject = a reference to my class, whatever that is...
    String string1 = (String) myObject;
    //versus:
    String string2 = myObject.toString();
    //or
    String string3 = "" + myObject;Is it clearer now?

  • Need help with Math related operations...

    I'm learning JAVA for more than 3 weeks and I really need help...
    I'm using SDK1.4 with Elixir IDE Lite (+patch installed).
    In the following screenshot <http://www.geocities.com/jonny_fyy/pics/java1.png>, I've got this error (when I right-click -> Compile) . Do you know what it means & how can I solve it?
    Here's how it should look if correct (pic scan from lab worksheet)... <http://www.geocities.com/jonny_fyy/pics/lab.jpg>
    Here's my java file... <http://www.geocities.com/jonny_fyy/FahToCeltxt.java>
    Thanks for helping :>

    Hi jonny
    One step ahead:
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    public class FahToCeltxt extends Applet implements ActionListener {
         TextField msgField ;
         String msg = null;
         int msgValue;
         Label title;
         Button b;
         public void init() {
              title = new Label("Enter degrees in Fahrenheit: ");
              add(title);
              msgField = new TextField (10);
              add(msgField);
    //          msgField.addTextListener(this);
              b = new Button("Convert");
              b.addActionListener(this);
              add(b);
    //     public void textValueChanged(TextEvent event) {
    //          msgValue = Integer.parseInt(msgField.getText());
    //          repaint();
         public void paint (Graphics g) {
              int result = (msgValue - 32) * 5/9 ;
              g.drawString("Degree Centigrade is " + result , 50, 50);
      public void actionPerformed(ActionEvent e) {
              msgValue = Integer.parseInt(msgField.getText());
              repaint();
    }Regards.

  • Need help with JTextArea and Scrolling

    import java.awt.*;
    import java.awt.event.*;
    import java.text.DecimalFormat;
    import javax.swing.*;
    public class MORT_RETRY extends JFrame implements ActionListener
    private JPanel keypad;
    private JPanel buttons;
    private JTextField lcdLoanAmt;
    private JTextField lcdInterestRate;
    private JTextField lcdTerm;
    private JTextField lcdMonthlyPmt;
    private JTextArea displayArea;
    private JButton CalculateBtn;
    private JButton ClrBtn;
    private JButton CloseBtn;
    private JButton Amortize;
    private JScrollPane scroll;
    private DecimalFormat calcPattern = new DecimalFormat("$###,###.00");
    private String[] rateTerm = {"", "7years @ 5.35%", "15years @ 5.5%", "30years @ 5.75%"};
    private JComboBox rateTermList;
    double interest[] = {5.35, 5.5, 5.75};
    int term[] = {7, 15, 30};
    double balance, interestAmt, monthlyInterest, monthlyPayment, monPmtInt, monPmtPrin;
    int termInMonths, month, termLoop, monthLoop;
    public MORT_RETRY()
    Container pane = getContentPane();
    lcdLoanAmt = new JTextField();
    lcdMonthlyPmt = new JTextField();
    displayArea = new JTextArea();//DEFINE COMBOBOX AND SCROLL
    rateTermList = new JComboBox(rateTerm);
    scroll = new JScrollPane(displayArea);
    scroll.setSize(600,170);
    scroll.setLocation(150,270);//DEFINE BUTTONS
    CalculateBtn = new JButton("Calculate");
    ClrBtn = new JButton("Clear Fields");
    CloseBtn = new JButton("Close");
    Amortize = new JButton("Amortize");//DEFINE PANEL(S)
    keypad = new JPanel();
    buttons = new JPanel();//DEFINE KEYPAD PANEL LAYOUT
    keypad.setLayout(new GridLayout( 4, 2, 5, 5));//SET CONTROLS ON KEYPAD PANEL
    keypad.add(new JLabel("Loan Amount$ : "));
    keypad.add(lcdLoanAmt);
    keypad.add(new JLabel("Term of loan and Interest Rate: "));
    keypad.add(rateTermList);
    keypad.add(new JLabel("Monthly Payment : "));
    keypad.add(lcdMonthlyPmt);
    lcdMonthlyPmt.setEditable(false);
    keypad.add(new JLabel("Amortize Table:"));
    keypad.add(displayArea);
    displayArea.setEditable(false);//DEFINE BUTTONS PANEL LAYOUT
    buttons.setLayout(new GridLayout( 1, 3, 5, 5));//SET CONTROLS ON BUTTONS PANEL
    buttons.add(CalculateBtn);
    buttons.add(Amortize);
    buttons.add(ClrBtn);
    buttons.add(CloseBtn);//ADD ACTION LISTENER
    CalculateBtn.addActionListener(this);
    ClrBtn.addActionListener(this);
    CloseBtn.addActionListener(this);
    Amortize.addActionListener(this);
    rateTermList.addActionListener(this);//ADD PANELS
    pane.add(keypad, BorderLayout.NORTH);
    pane.add(buttons, BorderLayout.SOUTH);
    pane.add(scroll, BorderLayout.CENTER);
    addWindowListener( new WindowAdapter()
    public void windowClosing(WindowEvent e)
    System.exit(0);
    public void actionPerformed(ActionEvent e)
    String arg = lcdLoanAmt.getText();
    int combined = Integer.parseInt(arg);
    if (e.getSource() == CalculateBtn)
    try
    JOptionPane.showMessageDialog(null, "Got try here", "Error", JOptionPane.ERROR_MESSAGE);
    catch(NumberFormatException ev)
    JOptionPane.showMessageDialog(null, "Got here", "Error", JOptionPane.ERROR_MESSAGE);
    if ((e.getSource() == CalculateBtn) && (arg != null))
    try{
    if ((e.getSource() == CalculateBtn) && (rateTermList.getSelectedIndex() == 1))
    monthlyInterest = interest[0] / (12 * 100);
    termInMonths = term[0] * 12;
    monthlyPayment = combined * (monthlyInterest / (1 - (Math.pow (1 + monthlyInterest,  -termInMonths))));
    lcdMonthlyPmt.setText(calcPattern.format(monthlyPayment));
    if ((e.getSource() == CalculateBtn) && (rateTermList.getSelectedIndex() == 2))
    monthlyInterest = interest[1] / (12 * 100);
    termInMonths = term[1] * 12;
    monthlyPayment = combined * (monthlyInterest / (1 - (Math.pow (1 + monthlyInterest,  -termInMonths))));
    lcdMonthlyPmt.setText(calcPattern.format(monthlyPayment));
    if ((e.getSource() == CalculateBtn) && (rateTermList.getSelectedIndex() == 3))
    monthlyInterest = interest[2] / (12 * 100);
    termInMonths = term[2] * 12;
    monthlyPayment = combined * (monthlyInterest / (1 - (Math.pow (1 + monthlyInterest,  -termInMonths))));
    lcdMonthlyPmt.setText(calcPattern.format(monthlyPayment));
    catch(NumberFormatException ev)
    JOptionPane.showMessageDialog(null, "Invalid Entry!\nPlease Try Again", "Error", JOptionPane.ERROR_MESSAGE);
    }                    //IF STATEMENTS FOR AMORTIZATION
    if ((e.getSource() == Amortize) && (rateTermList.getSelectedIndex() == 1))
    loopy(7, 5.35);
    if ((e.getSource() == Amortize) && (rateTermList.getSelectedIndex() == 2))
    loopy(15, 5.5);
    if ((e.getSource() == Amortize) && (rateTermList.getSelectedIndex() == 3))
    loopy(30, 5.75);
    if (e.getSource() == ClrBtn)
    rateTermList.setSelectedIndex(0);
    lcdLoanAmt.setText(null);
    lcdMonthlyPmt.setText(null);
    displayArea.setText(null);
    if (e.getSource() == CloseBtn)
    System.exit(0);
    private void loopy(int lTerm,double lInterest)
    double total, monthly, monthlyrate, monthint, monthprin, balance, lastint, paid;
    int amount, months, termloop, monthloop;
    String lcd2 = lcdLoanAmt.getText();
    amount = Integer.parseInt(lcd2);
    termloop = 1;
    paid = 0.00;
    monthlyrate = lInterest / (12 * 100);
    months = lTerm * 12;
    monthly = amount *(monthlyrate/(1-Math.pow(1+monthlyrate,-months)));
    total = months * monthly;
    balance = amount;
    while (termloop <= lTerm)
    displayArea.setCaretPosition(0);
    displayArea.append("\n");
    displayArea.append("Year " + termloop + " of " + lTerm + ": payments\n");
    displayArea.append("\n");
    displayArea.append("Month\tMonthly\tPrinciple\tInterest\tBalance\n");
    monthloop = 1;
    while (monthloop <= 12)
    monthint = balance * monthlyrate;
    monthprin = monthly - monthint;
    balance -= monthprin;
    paid += monthly;
    displayArea.setCaretPosition(0);
    displayArea.append(monthloop + "\t" + calcPattern.format(monthly) + "\t" + calcPattern.format(monthprin) + "\t");
    displayArea.append(calcPattern.format(monthint) + "\t" + calcPattern.format(balance) + "\n");
    monthloop ++;
    termloop ++;
    public static void main(String args[])
    MORT_RETRY f = new MORT_RETRY();
    f.setTitle("MORTGAGE PAYMENT CALCULATOR");
    f.setBounds(600, 600, 500, 500);
    f.setLocationRelativeTo(null);
    f.setVisible(true);
    }need help with displaying the textarea correctly and the scroll bar please.
    Message was edited by:
    new2this2020

    What's the problem you're having ???
    PS.

  • Need help with my HttpConnection From Midlet To Servlet...

    NEED HELP ASAP PLEASE....
    This class is supposed to download a file from the servlet...
    the filename is given by the midlet... and the servlet will return the file in bytes...
    everything is ok in emulator...
    but in nokia n70... error occurs...
    Http Version Mismatch shows up... when the pout.flush(); is called.. but when removed... java.io.IOException: -36 occurs...
    also i have posted the same problem in nokia forums..
    please check also...
    http://discussion.forum.nokia.com/forum/showthread.php?t=105567
    now here are my codes...
    midlet side... without pout.flush();
    public class DownloadFile {
        private GmailMidlet midlet;
        private HttpConnection hc;
        private byte[] fileData;
        private boolean downloaded;
        private int lineNumber;
    //    private String url = "http://121.97.220.162:8084/ProxyServer/DownloadFileServlet";
        private String url = "http://121.97.221.183:8084/ProxyServer/DownloadFileServlet";
    //    private String url = "http://121.97.221.183:8084/ProxyServer/Attachments/mark.ramos222/GmailId111d822a8bd6f6bb/01032007066.jpg";
        /** Creates a new instance of DownloadFile */
        public DownloadFile(GmailMidlet midlet, String fileName) throws OutOfMemoryError, IOException {
            System.gc();
            setHc(null);
            OutputStream out = null;
            DataInputStream is= null;
            try{
                setHc((HttpConnection)Connector.open(getUrl(), Connector.READ_WRITE));
            } catch(ConnectionNotFoundException ex){
                setHc(null);
            } catch(IOException ioex){
                ioex.printStackTrace();
                midlet.alertScreen = new AlertScreen("Error C1", ioex.toString(),
                        null, AlertType.ERROR);
                midlet.alertScreen.setTimeout(Alert.FOREVER);
                midlet.display.setCurrent(midlet.alertScreen);
            try {
                if(getHc() != null){
                    getHc().setRequestMethod(HttpConnection.POST);
                    getHc().setRequestProperty("Accept","*/*");
                    getHc().setRequestProperty("Http-version","HTTP/1.1");
                    lineNumber = 1;
                    getHc().setRequestProperty("CONTENT-TYPE",
                            "text/plain");
                    lineNumber = 2;
                    getHc().setRequestProperty("User-Agent",
                            "Profile/MIDP-2.0 Configuration/CLDC-1.1");
                    lineNumber =3;
                    out = getHc().openOutputStream();
                    lineNumber = 4;
                    PrintStream pout = new PrintStream(out);
                    lineNumber = 5;
                    pout.println(fileName);
                    lineNumber = 6;
    //                pout.flush();
                    System.out.println("File Name: "+fileName);
                    lineNumber = 7;
                    is = getHc().openDataInputStream();
                    long len = getHc().getLength();
                    lineNumber = 8;
                    byte temp[] = new byte[(int)len];
                    lineNumber = 9;
                    System.out.println("len "+len);
                    is.readFully(temp,0,(int)len);
                    lineNumber = 10;
                    setFileData(temp);
                    lineNumber = 11;
                    is.close();
                    lineNumber = 12;
                    if(getFileData() != null)
                        setDownloaded(true);
                    else
                        setDownloaded(false);
                    System.out.println("Length : "+temp.length);
                    midlet.setAttachFile(getFileData());
                    lineNumber = 13;
                    pout.close();
                    lineNumber = 14;
                    out.close();
                    lineNumber = 15;
                    getHc().close();
            } catch(Exception ex){
                setDownloaded(false);
                ex.printStackTrace();
                midlet.alertScreen = new AlertScreen("Error C2+ line"+lineNumber,
                        ex.toString()+
                        " | ",
                        null, AlertType.ERROR);
                midlet.alertScreen.setTimeout(Alert.FOREVER);
                midlet.display.setCurrent(midlet.alertScreen);
        public HttpConnection getHc() {
            return hc;
        public void setHc(HttpConnection hc) {
            this.hc = hc;
        public String getUrl() {
            return url;
        public void setUrl(String url) {
            this.url = url;
        public byte[] getFileData() {
            return fileData;
        public void setFileData(byte[] fileData) {
            this.fileData = fileData;
        public boolean isDownloaded() {
            return downloaded;
        public void setDownloaded(boolean downloaded) {
            this.downloaded = downloaded;
    }this is the midlet side with pout.flush();
    showing Http Version Mismatch
    public class DownloadFile {
        private GmailMidlet midlet;
        private HttpConnection hc;
        private byte[] fileData;
        private boolean downloaded;
        private int lineNumber;
    //    private String url = "http://121.97.220.162:8084/ProxyServer/DownloadFileServlet";
        private String url = "http://121.97.221.183:8084/ProxyServer/DownloadFileServlet";
    //    private String url = "http://121.97.221.183:8084/ProxyServer/Attachments/mark.ramos222/GmailId111d822a8bd6f6bb/01032007066.jpg";
        /** Creates a new instance of DownloadFile */
        public DownloadFile(GmailMidlet midlet, String fileName) throws OutOfMemoryError, IOException {
            System.gc();
            setHc(null);
            OutputStream out = null;
            DataInputStream is= null;
            try{
                setHc((HttpConnection)Connector.open(getUrl(), Connector.READ_WRITE));
            } catch(ConnectionNotFoundException ex){
                setHc(null);
            } catch(IOException ioex){
                ioex.printStackTrace();
                midlet.alertScreen = new AlertScreen("Error C1", ioex.toString(),
                        null, AlertType.ERROR);
                midlet.alertScreen.setTimeout(Alert.FOREVER);
                midlet.display.setCurrent(midlet.alertScreen);
            try {
                if(getHc() != null){
                    getHc().setRequestMethod(HttpConnection.POST);
                    getHc().setRequestProperty("Accept","*/*");
                    getHc().setRequestProperty("Http-version","HTTP/1.1");
                    lineNumber = 1;
                    getHc().setRequestProperty("CONTENT-TYPE",
                            "text/plain");
                    lineNumber = 2;
                    getHc().setRequestProperty("User-Agent",
                            "Profile/MIDP-2.0 Configuration/CLDC-1.1");
                    lineNumber =3;
                    out = getHc().openOutputStream();
                    lineNumber = 4;
                    PrintStream pout = new PrintStream(out);
                    lineNumber = 5;
                    pout.println(fileName);
                    lineNumber = 6;
                    pout.flush();
                    System.out.println("File Name: "+fileName);
                    lineNumber = 7;
                    is = getHc().openDataInputStream();
                    long len = getHc().getLength();
                    lineNumber = 8;
                    byte temp[] = new byte[(int)len];
                    lineNumber = 9;
                    System.out.println("len "+len);
                    is.readFully(temp,0,(int)len);
                    lineNumber = 10;
                    setFileData(temp);
                    lineNumber = 11;
                    is.close();
                    lineNumber = 12;
                    if(getFileData() != null)
                        setDownloaded(true);
                    else
                        setDownloaded(false);
                    System.out.println("Length : "+temp.length);
                    midlet.setAttachFile(getFileData());
                    lineNumber = 13;
                    pout.close();
                    lineNumber = 14;
                    out.close();
                    lineNumber = 15;
                    getHc().close();
            } catch(Exception ex){
                setDownloaded(false);
                ex.printStackTrace();
                midlet.alertScreen = new AlertScreen("Error C2+ line"+lineNumber,
                        ex.toString()+
                        " | ",
                        null, AlertType.ERROR);
                midlet.alertScreen.setTimeout(Alert.FOREVER);
                midlet.display.setCurrent(midlet.alertScreen);
        public HttpConnection getHc() {
            return hc;
        public void setHc(HttpConnection hc) {
            this.hc = hc;
        public String getUrl() {
            return url;
        public void setUrl(String url) {
            this.url = url;
        public byte[] getFileData() {
            return fileData;
        public void setFileData(byte[] fileData) {
            this.fileData = fileData;
        public boolean isDownloaded() {
            return downloaded;
        public void setDownloaded(boolean downloaded) {
            this.downloaded = downloaded;
    }here is the servlet side...
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            if(request.getMethod().equals("POST")){
                BufferedReader dataIN = request.getReader();
                String fileName = dataIN.readLine();
                File file = new File(fileName);
                String contentType = getServletContext().getMimeType(fileName);
                response.setContentType(contentType);
                System.out.println("Content Type: "+contentType);
                System.out.println("File Name: "+fileName);
                int size = (int)file.length()/1024;
                if(file.length() > Integer.MAX_VALUE){
                    System.out.println("Very Large File!!!");
                response.setContentLength(size*1024);
                FileInputStream fis = new FileInputStream(fileName);
                byte data[] = new byte[size*1024];
                fis.read(data);
                System.out.println("data lenght: "+data.length);
                ServletOutputStream sos = response.getOutputStream();
                sos.write(data);
    //            out.flush();
            }else{
                response.setContentType("text/plain");
                PrintWriter out = response.getWriter();
                BufferedReader dataIN = request.getReader();
                String msg_uid = dataIN.readLine();
                System.out.println("Msg_uid"+msg_uid);
                JDBConnection dbconn = new JDBConnection();
                String fileName = dbconn.getAttachment(msg_uid);
                String[] fileNames = fileName.split(";");
                int numFiles = fileNames.length;
                out.println(numFiles);
                for(int i = 0; i<numFiles; i++){
                    out.println(fileNames);
    out.flush();
    out.close();
    Message was edited by:
    Mark.Ramos222

    1) Have you looked up the symbian error -36 on new-lc?
    2) Have you tried the example in the response on forum nokia?
    3) Is the address "121.97.220.162:8084" accessible from the internet, on the device, on the specified port?

Maybe you are looking for