Appending a CR to a String

Hello,
actually I'm communicating with via my RS232 which works quite fine. Now there occured a little Problem, because I have to send a <CR> (I mean Carriage Return not "<CR>" as a String...) to the interface.
My only problem is how to append the <CR> to my String. For example I want to sent "Java<CR>". How do I implement ASCII-signs in 'normal' Strings ?
Thanx,
Findus

String CR = "\r";
String JavaCR = "Java" + CR;

Similar Messages

  • Appending a character to a string

    Hi I am trying to read in a sequence of numbers from a file, theyre of the form: 0.034 0.113 0.987 etc. What i am trying to do is read in the line of these numbers, and if we are not at a space in the numbers or at the end of file I want to append the numbers to a stringbuffer called TempHelix. For some reason my program keeps getting an error inside my while loop. Any help is appreciated
    StringBuffer TempHelix = null;
    int index = 0;
    if((current.charAt(index) != ' ') && index <current.length()){
    //PROBLEM HERE
    TempHelix = TempHelix.append(current.charAt(index));
    //NOW WE GET THE STRING THAT HAS BEEN MADE UP IN THE
    //LOOP AND PARSE TO A DOUBLE AND THEN INSERT INTO AN ARRAY
    String s = new String(TempHelix);
    TempDouble = Double.parseDouble(s);
    Helix[index] = TempDouble;
    index++
    //after adding to index we go back into loop and continue
    }

    here is what i have modified so far:
               double TempDouble = 0;
                 int index = 0;
                 if((current=dis.readLine()) != null){          
                 StringBuffer TempHelix = new StringBuffer(null);
                              if((current.charAt(index)!= ' ')){
                                       //PROBLEM HERE
                                       TempHelix.append(current.charAt(index));
                                       //TempHelix = TempHelix + current.charAt(index);
                                       String s = TempHelix.toString();
                                  TempDouble = Double.parseDouble(s);
                                       Helix[index] = TempDouble;
                                  System.out.println(Helix[index]);
                                  index++;
         }

  • How to append the User Agent String in IE11

    We use "Internet Explorer maintenance" GPO to append the standard User Agent String for IE9 with "ADFSIntAuth". "Internet Explorer maintenance" is deprecated and will not work anymore for IE11 and later.
    Now we want to move to IE11 and I can't find a solution to append the User Agent String. With GPO this isn't possible anymore (Why Microsoft?). And the registry keys I've tested won't do the job. I've tested 
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\User Agent\Post Platform
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\User Agent
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\User Agent\Post Platform
    So whats is the best way to append the user agent string for IE11?
    http://social.technet.microsoft.com/Forums/en-US/cdc999aa-faec-4aa5-9025-f12a524794f0/ie10-user-agent-string?forum=winserverGP didn't help.

    Thank you for the Reply Roger.
    I have already read the website you are referring to, but it doesn't say how to append the User Agent String.
    Only this:
    "Earlier versions of the browser included
    Pre-Platform and Post-platform registry value tokens in the user-agent string. However, this led to
    performance issues for customers of certain tools and add-ons. As a result, these tokens are now reported only through the
    navigator.userAgent property"
    With a dead link to the article "navigator.userAgent", but with a search I came to this article: http://msdn.microsoft.com/en-us/library/ie/ms534712(v=vs.85).aspx But also this article won't say how to append the User Agent String for all
    clients in a corporate environment.

  • Strings appending

    Hi, I am using an event  structure in a while loop. In each event I am have a stacked sequence. In each sequence i have to display a string . In the next sequence the string should be appended to the first sequence string in the string indicator. The vertical scrollbar function should be used to see the strings ddisplayed in the string indicator. How to do this in an event structure.
    Regards,
    Rajashekar

    Is this your wish?
    Attachments:
    strings appending.vi ‏12 KB

  • String won't copy to array

    I had to create an applet that would take in two binary numbers from the keyboard and would add/subtract/multiply them. To do this we needed an int array. But when i tried doing the method shown to us, it didnt work and it would literally output garbage. It was already due and i submitted it as is but this'll bug me unless i figure it out. The calculations should work (i think) but once i get the array problem fixed i could debug that. Thanks in advance.
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class proj2 extends JApplet implements ActionListener{
        JLabel p1, p2,answer;
        JTextField i1,i2;
        JButton plus, minus, multi;
        public void init(){
            p1=new JLabel("Enter first integer");
            p2=new JLabel("Enter second integer");
            i1=new JTextField(20);
            i2=new JTextField(20);
            plus=new JButton("+");
            minus=new JButton("-");
            multi=new JButton("*");
            answer=new JLabel("Answer is          ");
            JPanel north=new JPanel();
            north.setLayout(new GridLayout(2,2));
            north.add(p1);
            north.add(i1);
            north.add(p2);
            north.add(i2);
            JPanel south=new JPanel();
            south.setLayout(new GridLayout(1,3));
            south.add(plus);
            south.add(minus);
            south.add(multi);
            Container c=getContentPane();
            c.setLayout(new BorderLayout());
            c.add(north,BorderLayout.NORTH);
            c.add(answer,BorderLayout.CENTER);
            c.add(south,BorderLayout.SOUTH);
            plus.addActionListener(this);
            minus.addActionListener(this);
            multi.addActionListener(this);
            }//end init
                public void actionPerformed(ActionEvent x){
                    String a=i1.getText();
                    String b=i2.getText();
                    int[] top=new int[20];
                    int[] bottom=new int[20];
                    int[] ans=new int[20];
                    int[] one=new int[1];
                    one[0]=1;
                    int len=a.length();
                    int len2=b.length();
                    for (int i=len-1;i>=0;i--)
                            char c=a.charAt(i);
                            top[len-i]=(c-48);
                    for (int i=len2-1;i>=0;i--)
                            char c=b.charAt(i);
                            bottom[len2-i]=(c-48);
                    if (x.getSource()==plus){
                    ans=addbin(top,bottom);
                    answer.setText("The sum of "+top+" and "+bottom+" is "+ans+".");}
                    else if (x.getSource()==minus){
                    bottom=flipbits(bottom);
                    bottom=addbin(bottom,one);
                    ans=addbin(top,bottom);
                    answer.setText("The difference of "+a+" and "+b+" is "+ans+".");}
                    else {
                    for(int i=0;i<20;i++)
                        if (bottom==1)
    ans=addbin(ans,top);
    top=shift(top);
    answer.setText("The product of "+a+" and "+b+" is "+ans+".");
    }//end actionPerformed
    public int[] addbin(int[] x, int[] y){
    int carry=0;
    int[] ans=new int[20];
    for(int i=0;i<20;i++)
    int sum=x[i]+y[i]+carry;
    ans[i]=sum%2;
    carry=sum/2;
    return ans;
    }//end addbin
    public int[] flipbits(int[] x){
    for(int i=0;i<20;i++)
    x[i]=(x[i]+1)%2;
    return x;
    }//end flipbits
    public int[] shift(int[] x){
    int len=x.length;
    int[] newarray=new int[len+1];
    for(int i=0;i<len;i++)
    newarray[i]=x[i];
    newarray[len]=0;
    return newarray;
    }//end shift
    }//end class

    jlicata89 wrote:
    int[] ans=new int[20];
    answer.setText("The sum of "+top+" and "+bottom+" is "+ans+".");}
    answer.setText("The difference of "+a+" and "+b+" is "+ans+".");}
    answer.setText("The product of "+a+" and "+b+" is "+ans+".");
    You can't just append an array to a string. Arrays don't have a custom "toString" method, so its string representation is the default one, which looks like "garbage" to you. Depending on what you want to do, you can use Arrays.toString(), or write a custom method to turn it into a string representation of your choice.
    l33tard wrote:
    Try changing all occurrences of this:
    top[len-i]=(c-48);to:
    top[len-i] = (int)(c) - 48;
    That is completely useless. char's are automatically promoted to int's.

  • Append Multiple Control Images as a 2-D array/tabl​e ?

    All
    I am trying to generate a report and I wish to have the following pattern:
    Image      Blank      Image
    Blank      Image      Blank
    Image      Blank      Image
    Where I intend to place my control images at "Image" and no image at "Blank"
    I thought I can build a table of control images and append but it accepts only string/numeric tables.
    Is there a easier way to include images into WORD report, equivalent to: me inserting a 3x3 table in a word document, and pasting images in 1st row 1st column, 1st row 3rd colum, 2nd row 2nd colum, 3rd row 1st column, 3rd row 3rd column.
    Please let me know, thanks
    Kudos always welcome for helpful posts

    That example was cool. I wish to add images to table using control reference.
    I tried using the control reference to get image, save as a png and then use it to add images. Is there a way that I can use the control reference to add images to my table directly ?
    Kudos always welcome for helpful posts

  • How to append Objects in a file.

    i have the following sample code ,
    its not read data properly and throws Stream Corrupted Exception in the appended record. ( at Last statement of try block ).
    Thanks,
    import java.io.*;
    public class IOError {
    public static void main(String[] args) {
    try {
    ObjectOutputStream oos = new ObjectOutputStream(
    new FileOutputStream("data.dat"));
    oos.writeObject(new String("string 1"));
    oos.writeObject(new String("string 2"));
    oos.flush();
    oos.close();
    ObjectInputStream ois = new ObjectInputStream(new FileInputStream("data.dat"));
    System.out.println("----- Round 1 Starts ---------");
    System.out.println((String) ois.readObject());
    System.out.println((String) ois.readObject());
    ois.close();
    ObjectOutputStream oos2 = new ObjectOutputStream(
    new FileOutputStream("data.dat",true)); // Appending Data
    oos2.writeObject(new String("string 3"));
    oos2.flush();
    oos2.close();
    ObjectInputStream ois2 = new ObjectInputStream(new FileInputStream("data.dat"));
    System.out.println("----- Round 2 Starts ---------");
    System.out.println((String) ois2.readObject());
    System.out.println((String) ois2.readObject());
    System.out.println((String) ois2.readObject()); // Stream Corrupted Exception
    catch(Exception e) {
    System.out.println(e);

    Nasty. When you open an ObjectOutputStream, it will write a few initializing bytes, so if you really want to append objects to a file, then after you read the first two strings, you need to create a new ObjectInputStream that will read those bytes.
    You could write an object indicating that now you are done with this ObjectOutputStream, so when you read the file and read this object, you know you have to create a new ObjectInputStream.
    oos.writeObject(new String("string 1"));
    oos.writeObject(new String("string 2"));
    oos.writeObject(null); // null could be used if you know you won't write any other null's in your code.
    //... append
    oos.writeObject(new String("string 3"));
    oos.writeObject(null);
    // read:
    FileInputStream fis = new FileInputStream("data.dat");
    ObjectInputStream ois2 = new ObjectInputStream(fis);
    String s;
    while ((s = (String)ois2.readObject()) != null) {
      System.out.println(s);
    ois2 = new ObjectInputStream(fis);
    while ((s = (String)ois2.readObject()) != null) {
      System.out.println(s);

  • Mixed Arabic/Latin text confuson in a single String

    Hi all,
    I hope someone knows the answer to this issue!
    I've got an application in Java which calls another app via a stored procedure and callable statement, passing various parameters across. One of these parameters is a buffer containing transaction information.
    Now we're working on an Arabic language proof of concept, and when I create this buffer containing both Arabic, Latin and numeric data, the order of the string is messed up.
    E.g.
    The data may be (in order):
    I
    AED
    17
    &#1588;&#1575;&#1585;&#1577; &#1575;&#1604;&#1606;&#1602;&#1575;&#1591;
    1.7
    101010
    Test seventeen
    17D
    This appears in the buffer (with some padding) as:
    IAED17&#1588;&#1575;&#1585;&#1577; &#1575;&#1604;&#1606;&#1602;&#1575;&#1591; 1.7 101010Test seventeen 17D
    As you can see, the order has changed - the numeric fields appear to have been included with the Arabic text.
    This causes the API we're calling to break, as you can imagine - expected fields are not appearing in the right place in the buffer.
    The string for the buffer is being built as follows:
    StringBuffer paramBuffer = new StringBuffer(BUFFER_INITIAL_CAPACITY);
    while (iterator.hasNext()) {
    String fieldName = iterator.next().toString();
    // Get Object using field name from Vector.
    FieldApi field = (FieldApi)fields.get(fieldName);
    tempCtr = tempCtr + field.getLength();
    if (field.getLength() == 0) {
    break; // We have reached end of the fields
    //Add each formatted field to param.
    paramBuffer.append(field.getString());
    Now, I suspect that I could get around this by constructing a byte array and using a setBytes method on my callableStatement. However, the set up of my JDBC connection means that I can't use setBytes (translateBinary is set to true, giving a data type mismatch exception), and this set up is something I can't change.
    I'm sure this is a problem with the fact that Arabic languages are right to left rather than left to right, and the String I create attempts to format it in this manner (and gets it a little confused when a numeral is next to Arabic text). Is there a way I can tell the String to leave things exactly as they're added, rather than attempting to format them?
    Any help would be appreciated! :-)
    Cheers,
    Dan
    P.S. I'm aware that what is displayed and what is actually there may not be the same, but when I inspect the contents of the buffer in the stored procedure, the order is indeed wrong.

    Hi Dan,
    Some time ago a faced a similar problem whenn preparing text for display. I solved it by wrapping the text in a html table, thus forcing the elements to remain in the exact order I wnated them in. Something as follows:
    import java.awt.BorderLayout;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.SwingUtilities;
    public class MixedArabic {
        public static void main(String[] args) {
         SwingUtilities.invokeLater(new Runnable() {
             @Override
             public void run() {
              new MixedArabic().createGUI();
        private String[] parts = new String[] { "AED", "17",
             "\u0634\u0627\u0631\u0629 \u0627\u0644\u0646\u0642\u0627\u0637",
             "1.7", "101010", "Test seventeen", "17D" };
        private void createGUI() {
         JFrame frame = new JFrame();
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.add(new JLabel(createString(parts, false)),
              BorderLayout.PAGE_START);
         frame.add(new JLabel(createString(parts, true)), BorderLayout.PAGE_END);
         frame.pack();
         frame.setLocationRelativeTo(null);
         frame.setVisible(true);
        private String createString(String[] parts, boolean formatted) {
         StringBuilder sb = new StringBuilder();
         if (formatted) {
             sb.append("<html><table><tr>");
         for (String part : parts) {
             sb.append(formatted ? "<td>" : ' ');
             sb.append(part);
             sb.append(formatted ? "</td>" : ' ');
         if (formatted) {
             sb.append("</tr></table></html>");
         return sb.toString();
    }Piet

  • String parsing - better solution needed :-(

    Hi Folks,
    Basically I will be taking in a string that represents the name of the output file the user wants, this will be specified in an xml file. The issue I have is that it needs to have non-static elements as part of the name as well (like a timestamp). This can come from two places: 1) the applications map 2)Predefined list of functions. Anything that will be comng from the map will have square brackets around it [], whilst anything the refers to a function will be inside curly brackets {}.
    So I may get a string in the form: filename_[user.id]_{datestamp}.pdf
    This should be output in a file called: filename_12345_2811208.pdf
    My issue is with evaluating the string, to determine what needs to be left as is, replaced with a value from a function, or replaced with a value from the map. I have looked at tokenizing the string and using indexof, but these are more trouble than they are worth. My current solution is, to have 4 booleans- one representing an open and close bracket of each type. When two matching booleans are true (i.e. detected an open and closed square bracket) take the sub-string between the brackets (to do this I use two ints representing the index of the brackets), evaluate it and append it to the output string.
    I have tested this and it works- but I was wondering if there is some other method that works better, as quite frankly my solution is the sort of embarassing crud you would see from a first year student programmer. Any help at all would be massively appreciated.
    Cheers,
    Max

    Hi swmtgoet_x,
    Thanks for the speedy reply- and your understanding of the problem is spot on.
    I had looked at the replace method- the only issue with that is that I have no way of knowing which value the users will want from the map (depending on how they have it implemented there could be hundreds of things in there), so to search the string for any value in the map would be hugely ineffecient :-(
    But having said that- I could look at using that approach for "pre-defined function"- I don't think there will be many of these, but in typical fashion no one has seen fit to gove me a list yet.....so I get to guess. :-s

  • EOS character not appended?

    I am attempting to write an application that in part will control an Anritsu MP1570A Sonet Analyzer. This instrument departs from the IEEE standard in that it requires tx or rx messages to be terminated with a carriage return <\n>.
    In the custom properties for the NI GPIB Control, there is an "advanced" tab under which one of the options available defines the EOS character. From this dropdown list I selected "\10(LF)", (10 corresponds to the ASCII value of a linefeed.) I also checked the "EOS ends read" and "Append EOS on write" options.
    After selecting the correct device address and changing to the "test" page of the properties, I find that the instrument still does not respond to *IDN?, and upon examination of the captured data with
    NI Spy, I find that the linefeed has not been appended.
    If, on the test page of the control properties, I type *IDN?\n the instrument responds correctly. From what I can tell the GPIB control is ignoring the settings I entered for the EOS character, but I'm hoping that someone can point out something I've overlooked.
    In working developing code for this instrument I have so far been manually appending chr$(10) to every string. I'm not sure if that has anything to do with problems I've been having associated with command timing, but I'm sure it has not helped.
    Thanks in advance to anyone with advice!
    JG

    Hi Jerry,
    The test page does not append the EOS character, however if you do it with source code, it will - without you having to add the character...
    For example if you do the following in code..
    CWGPIB1.Configure
    CWGPIB1.Write "*IDN?"
    The EOS string (if there is one specified) will automatically be appended to the outgoing string. In NI-SPY it will show up as a dot, i.e. "*IDN?." and the count will be 6 bytes (not 5).
    Further, if you dbl-click on the ibwrt statement, and look at the buffer tab, then you should see the hex code for your outgoing string with the EOS character attached...
    I'm using Measurement Studio 6.0 to test this..
    Hope that helps some...
    Nandan Dharwadker
    Staff Software Engineer
    Measurement Studio Hardware Team

  • Need some  String Logic....!

    Hi,
    I have a String str="-a-b_-c-d" ,
    I want to rename the String by making the following changes.
    If a is -ve(ie., -a) then it should be changed to aW (ie, '-a'='aW')
    If a is +ve(ie., a) then it should be changed to  aE (ie, '-a'='aE')
    If b is -ve(ie., -b) then it should be changed to bS (ie, '-b'='bS')
    If b is +ve(ie., b) then it should be changed to bN (ie, '-b'='bN')
    Same logic of 'a' for 'c' as well.
    ie., '-c'='cW' and 'c'='cE'
    Same logic of 'b' for 'd' as well.
    ie., '-d'='dS' and 'd'='dN'
    The output of the above String str should be str2="aWbS_cWdS";
    Some examples str="a-b_-cd" == "aEbS_cWdN"
    Thanks in Advance..,
    regards
    Rao.

    I tend to agree with kamranA, but I had a few minutes and felt like being a sucker for a challenge, so I took a shot at it. BUT DON'T LET IT HAPPEN AGAIN! Anyway, not that this code is so wonderful, but all caveats apply . . . test and use at your own risk:
    public class Str2CharII {
      public static void main(String[] argv) {
        System.out.println("The result is: "+getNewString(argv[0]));
      public static String getNewString(String s) {
        StringBuffer sb    = new StringBuffer();
        char[]       chars = s.toCharArray();
        int          ind   = -2;
        for (int idx=0; idx < chars.length; idx++) {
          switch (chars[idx]) {
            case '-': {
              ind = idx;
              continue;
            case '_': {
              sb.append("_");
              continue;
            case 'a': {
              if ( idx == (ind + 1) ) { sb.append("aW"); }
              else                    { sb.append("aE"); }
              continue;
            case 'b': {
              if ( idx == (ind + 1) ) { sb.append("bS"); }
              else                    { sb.append("bN"); }
              continue;
            case 'c': {
              if ( idx == (ind + 1) ) { sb.append("cW"); }
              else                    { sb.append("cE"); }
              continue;
            case 'd': {
              if ( idx == (ind + 1) ) { sb.append("dS"); }
              else                    { sb.append("dN"); }
              continue;
        return(new String(sb));
    }~Bill

  • Please Suggest best way to pass Strings in a pipeline

    I'm working in a project in which a line passes in a pipeline kind of situation.
    The String is passed between different modules and each module adds some more data to it (or may even remove some of it).
    Which is the best way to pass the String? I think java.lang.String might not be an efficient method because the String i'll be passing will be modified many times.
    Thanx

    Yes. StringBuffer or StringBuilder you can use.
    String string = "test";
    StringBuffer sb = new StringBuffer(string);later you will add some more strings to the StringBuffer
    sb.append("Hello World");No additiional String object will be created.

  • String Comparsion

    A very basic question regarding strings.
    I have a String to which I append a "*" at the end of the String
    ex: S1 - Email Address
    S2( Appended Label) = Email Address*
    I have a HashMap - which stores S1.
    Now I want to compare S1 and S2 (omitting the "*") to check if they are equal.
    I tried
    if(s2.endswith("*")) {
      String s3 = s2.trim();
    if(s3.equals(s1) {
      do something
    }this didn't seem to work
    thnx

    Or write your own method:
    String rTrim( String in, char cut ) {
      char[] chars = in.toCharArray();
      StringBuffer buf = new StringBuffer();
      for ( int i = 0; i < chars.length; i++ ) {
        if ( chars[i] != cut ) buf.append( ""+chars[i] );
      return( new String( buf ) );
    }Wierd, it would not let me 'paste' that in ... that's why my prev msg was empty.

  • How can u get the matching percentage whenever compare the pdf files(compare the strings)

    Actually I want matching percentage whenever compare the pdf files.First I had completed 
    read the pdf files content into string
    my code like as
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.IO;
    using iTextSharp.text;
    using iTextSharp.text.pdf;
    using iTextSharp.text.pdf.parser;
    namespace WindowsFormsApplication1
    public partial class Form1 : Form
    string str1;
    string filename;
    string path;
    string str2;
    public Form1()
    InitializeComponent();
    private void button1_Click(object sender, EventArgs e)
    OpenFileDialog openFileDialog = new OpenFileDialog();
    openFileDialog.CheckFileExists = true;
    openFileDialog.AddExtension = true;
    openFileDialog.Filter = "PDF files (*.pdf)|*.pdf";
    DialogResult result = openFileDialog.ShowDialog();
    if (result == DialogResult.OK)
    filename = Path.GetFileName(openFileDialog.FileName);
    path = Path.GetDirectoryName(openFileDialog.FileName);
    textBox1.Text = path + "\\" + filename;
    private void button2_Click(object sender, EventArgs e)
    OpenFileDialog openFileDialog = new OpenFileDialog();
    openFileDialog.CheckFileExists = true;
    openFileDialog.AddExtension = true;
    openFileDialog.Filter = "PDF files (*.pdf)|*.pdf";
    DialogResult result = openFileDialog.ShowDialog();
    if (result == DialogResult.OK)
    filename = Path.GetFileName(openFileDialog.FileName);
    path = Path.GetDirectoryName(openFileDialog.FileName);
    textBox2.Text = path + "\\" + filename;
    public static string ExtractTextFromPdf(string filename)
    using (PdfReader r = new PdfReader(filename))
    StringBuilder text = new StringBuilder();
    for (int i = 1; i <= r.NumberOfPages; i++)
    text.Append(PdfTextExtractor.GetTextFromPage(r, i));
    string result = text.ToString();
    return result;
    public static string Extract(string filename)
    using (PdfReader r = new PdfReader(filename))
    StringBuilder text = new StringBuilder();
    for (int i = 1; i <= r.NumberOfPages; i++)
    text.Append(PdfTextExtractor.GetTextFromPage(r, i));
    string result1 = text.ToString();
    return result1;
    private void button3_Click(object sender, EventArgs e)
    str1 = Form1.ExtractTextFromPdf(textBox1.Text);
    str2 = Form1.Extract(textBox2.Text);
    }Finally how can u get the matching percentage whenever compare the pdf files(compare the strings)please help me.thank u

    Hi,
    Based on your code, I see your code related to
    iTextSharp Pdf.
    iText is a third party library to create PDF originally written for java. iTextSharp is
    the C# adaptation of that library.
    Question regarding iText are better asked on the iText forum, rather than the Microsoft Forum:
    http://itextpdf.com/support
    Thanks for your understanding.
    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.

  • Building SQL String ?

    I am trying to build a SQL String and send it to the database...
    this is how i am trying to form a query string
    StringBuffer sBuff = new StringBuffer(250);
    sBuff.append("old information")
    sBuff.append("new history added twice");
    String caseObjId = "2567034";
    StringBuffer queryBuff = new StringBuffer(250);
    queryBuff.append("UPDATE table_case ");
    queryBuff.append("SET case_history =" + sBuff);
    queryBuff.append("WHERE objid =" + caseObjId);
    i am getting SQL Exception saying
    com.sybase.jdbc2.jdbc.SybSQLException: Incorrect syntax near 'information'.
    let me know what where i am doing mistake
    thanks
    KM

    The previous posters are right on target for debugging your problem; if you printed out the query that's giving you problems, you would see:
    UPDATE table_case
    SET case_history =old informationnew history added twice
    WHERE objid =2567034 and the problem then becomes obvious that the string/varchar data needs to be quoted.
    That will fix your immediate problem.
    However, since you are obviously a newbie, I'll tell you how to fix 2 or 3 more problems; don't use Statement, use PreparedStatement and bind your parameter values.
    <rant>
    First, when a database executes a SQL statement for the first time, it has to "parse" it. "parsing" is an awful like compiling in that it often takes 100 times longer or more to compile a bit of code than it does to execute it. A good database will check a cache of parsed SQL to see if it doesn't need to parse again, but it often relies on an exact match of the SQL. If you use Statement and change the value of case_history or objid, it's not an exact match. However, if you use PreparedStatements, your values aren't part of the SQL; therefore you get a lot more matches in the parse cache and the database saves a huge amount of work.
    Second, when you build up SQL with embedded values like you're doing, you have to deal with any special characters appropriately; in particular the single quote character; for example, if you have a LAST_NAME column, you need to support the name "O'Conner"; the single-quote in the middle has to be recognized and properly escaped. This problem simply goes away with parameter bindings; the code and the data are widely seperated and there's no question where the boundary is.
    Third, building up SQL in the way you did is the technique that causes a major security hole an poorly coded applications. Let's say you're building an e-commerce site that will keep customer credit card numbers on file (risky) and want a function to display credit card numbers given an account number (not really a good idea, but it illustrates the technique). You have code like:
    StringBuffer queryBuff = new StringBuffer();
    queryBuff.append("SELECT CC_FIRST_NAME, CC_LAST_NAME, CC_NUMBER, CC_EXP ");
    queryBuff.append("FROM CARD_DATA);
    queryBuff.append("WHERE account_number  =" + acct_number);this will work just great when a user enters their account number of "1234567", and it will work just great (for the hacker) when the account number is entered as "1234567 or (CC_FIRST_NAME = 'Bill' and CC_LAST_NAME = 'Gates')"; the hacker's add-ons are treated as code, not data, and the e-commerce site spits up a customer's data to an authorized person. Again, parameter binding prevents this and add-ons get treated as part of the account number, probably generating a data-type error on the database. Obviously, you can validate the data to numerics in this example, but if you use PreparedStatement instead, you don't have to think, it takes care of itself.
    </rant>

Maybe you are looking for

  • Can I merge calendar on my mac with a calendar on iCloud?

    Hi I have a claendar that shows on the dropdown list as the default calendar ON MY MAC.  It syncs with my microsoft outlook calendar at work so I can see all my work calendar items on my home mac. The drop down list also shows iCloud as having a sepa

  • Business rules for Adhoc

    Hi All, I have created a web form and I want to do the Adhoc analysis on it , when right click the form and go to Adhoc session , I see the "Business rules for Adhoc" is coming as "calculate Currencies" and "calculate Form". But I want to add my Busi

  • How to Create Custom Usage Decisions

    Hi, I am working in ECC 6.0. I want to create a Custom Usage decision (Plant Specific). I can not remember where to go to set this up? If I use transaction QS41 and set up my own Code Group under Catalog type 3 (Usage Decision), where can I attach th

  • IMac WIFI problem - New Clue?

    The saga continues. I have seen it all. "Its a DNS problem." "Its your PRAM." "No, its Lion." The Geniuses even swapped out my WIFI card. Nothing works. So today I was running the PING command continuously in a terminal window, while trying to get to

  • CS4 Project won't open

    Please help if anyone has had this problem. I have edited a D ance Show using four layers of Video (down converted from AVCHD using Panasonic's con version program to allow 4-layers of multicam). After editing about 1 1/2 hours of the project it now