StringBuffer and JLabel?

Is it possible to pass a StringBuffer to a JLabel? If so, how is it done?
I'm trying to create a calculator - so pressing the a number button will append to a stringbuffer. That stringbuffer will then be part of the JLabel.
Currently, I have:
<snip>
          //zero listener
          zero.addActionListener(this);
          zero.addActionListener(
          new ActionListener() {
          public void actionPerformed(ActionEvent e) {
               readoutlabel.setText("not sure"); // this is where the string has to be implemented
               });</snip>
I tried putting in a stringbuffer but it didn't seem to work.
advTHANKSance

You don't have to memorize the documentation. It does help if you look in it to find information you need. In your case you needed a method that makes a StringBuffer into a String. So, if you look in the documentation you'll find there are three such methods. Two of them are different forms of substring() and the third is toString(). A quick look at their descriptions tells you which one you want.
By all means ask questions here, but (as you will have noticed) people don't always like being used as a resource for looking things up for you.
You're new to Java, so quite likely it hadn't occurred to you that you needed a String. So put on your thick skin. A look in the JLabel documentation would have told you that... but we already went there.

Similar Messages

  • How do you determine StringBuffer and List capacity?

    hi all,
    I'm curious and would like to post this query that how to determine the StringBuffer and List capacity after read some of the Java Platform performance book. Some of this performance books simply tells number of capacity brieftly without telling what and how does the capacity stand for.
    First, the book mentioned StringBuffer(50). Note, my question is that what is this 50 stand for? 50 Characters? or any. Can someone help me to rectify this?
    Second, List. ArrayList(0.75). And what is this 0.75(by default) stand for? A heap space? Then how many of them? How many objects that can be stored for not to "exceed 0.75"?
    Please help. :)
    regards,
    Elvis
    scjp

    I think the capacity is the CURRENT size of a container. But it is not equal to the number of elements that container currently hold. Just like, a house can have 10 people within, but problably only 3 people at some time. Also, the capacity is not equal to the maximum size, because container can grows automatically.
    For example, a container whose capacity is 50, currently has 30 elements in it. If you add 10 elements more. That is only an addition operation. But if you add 30 elements to it. Then the container first enlarge its capacity according to some arithmetic(a enlarging rate), secondly carry out the addition operation.
    Now that the capacity is the size, it should be a number standing for HOW MANY elements.... In the case of StringBuffer, it should be how many chars; in the case of ArrayList, it should be how many Objects. I do not think 0.75 can stand for a capacity. Prabaly, it was used to describe the enlarging rate when containers need to contain more elements than its current capacity. ( From JDK API, you can see the type of capacity is int ).
    For containers and alike, the questions "how many I can hold" and "how many I am holding", "Do I can enlarge"? are helpful for understanding how it works.

  • Having some problems with ImageIcons and JLabels

    I'm making a checkers game, and so far it's going pretty well.
    I've got the basic game down, and you can move pieces, jump, your turn ends when you can't jump anymore, etc...
    However, I've had three problems:
    1.) I'm using JLabels to display my board (8 x 8.. well actually 9 x 9 for an outer row labelled A,B,C,D.. 1,2,3,4...) Anyway, I create the JLabels using something that looks like \:
    JLabel square = new JLabel(new ImageIcon("pic.png"));
    Now, the picture loads properly, but it seems like the picture is being cropped, and the top and bottom are getting chopped off, so my 36 x 36 pixel *.gif appears to be 36 x 30.
    You can see how there is a gap created in:
    http://img235.imageshack.us/img235/7765/prob13ky.jpg
    Now the problem may be with the GridLayout I am using, but I set the distance between the components in the container to be 0, 0 so I don't think that GridLayout is chopping my icons. I've also tried setPreferredSize(new Dimension(36,36))
    for both my ImageIcons and JLabels and for my container (which I set to size 2000,2000, just to make sure there was room). If anyone can help me, it's be appreciated.
    2.) I used to be able to view my outside row/column of squares that said A,B,C,D.... and 1,2,3,4... with the square in the corner having a random pic. For some reason now (have no clue why) I now see only the pic in the corner, and then a little gray smudge diagonally under it.
    Pic:
    http://img347.imageshack.us/img347/8308/prob24im.jpg
    I don't know what's wrong. I'm pretty sure it's none of the new methods I've written, as those are all in my static void main (String[] ar) ...... and if I comment all the methods in my main except where I first make the JFrame and set it visible, it still turns out like that. repaint() doesn't help.
    3.) For some reason, when I move another window (AIM, the console window, etc...) over my Swing window, it "erases" (turns gray, just wipes clean) the part where I have my squares that have pieces.
    What's weird is that:
    The border pieces (err.. my one visible corner piece from my second problem) don't get wiped, and some debugging text and JLabels (in a different JPanel) are fine. I don't think the JPanel matters though; the border pieces and the playing squares (which get wiped) are in the same JPanel and same array of squares.
    repaint(); also erases ALL of my playing squares, whereas moving a window over them would only erase the part that the window covered.
    Also, I added a mouseListener so that whenever I move the mouse over a square, it changes the image (to a tinted version, so you know the mouse is over it) and when you move the mouse away, it returns to normal. However, if I wildly swing the mouse around the area, it seems to lock up and freeze for a few seconds. Is there anything I can do to prevent this??
    Thanks in advance.

    It is hard to tell what your problems are without any code at all (I saw your images, but that doesn't make it easy to see what is wrong in your code). If you do post code, please use code tags (see button above posting box).
    I've seen your MouseListener problem before--we had the exact same issue in our code at work. It would freeze up while it processed all of the mouse events (unbearably slow). I'm not at work right now, so I don't recall how it was fixed. Essentially, you need to only process the event periodically. You need to only update the image if the mouse switches squares. Or, only update the image if the distance from the last mouse event is more than some specified amount. We might also have checked the time difference between mouse events before processing a new one. I could look at the code at work tomorrow, if you are still having trouble.

  • About a JTree of mixed String and JLabel leafs

    Dear Java and Swing freaks,
    Why do I get the text code instead of the expected JLabel in the leaves of my JTree ?
    I want to construct a Jtree in which each tree leaf is made of a JLabel (displaying an amount and with a coloured background), followed by a normal String (the label of this amount).
    An array (of arrays) of Ojects describes the tree that I want to display in a Swing JPanel of Container, as in the "2.1 Simple JTREE Example" at URL
    http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-JTree.html
    So, using the "DefaultMutableTreeNode" class and a "private DefaultMutableTreeNode processHierarchy(Object[] hierarchy)" re-entering function.
    Either the 'nodeSpecifier' is of type 'new Object[]', and the 'processHierarchy()' interpretes it as a new node,
    Or the 'nodeSpecifier' is of type 'JLabel' (or 'String'), and the 'processHierarchy()' has to interprete it as a new leaf.
    Of course, 'JLabel', as 'String', is also a subclass of 'Object'.
            BigDecimal TotalDistrNetBeh1= 1.11;
            Object[] hi�rarchie =
            { "Blablabla",
              new Object[]
              { "Bloc de compteurs",
                new Object[] { "Total1" + " : The 1st listed item = The title of this node",
                                     new JLabel(TotalDistrNetBeh1.toPlainString()),
                       /* + "DistrNetBeh1" */
                                     new JLabel(" 2.22")
                       /* + "DistrNetBeh2" */
                new Object[] { "Total2" + " : Title of this node",
                                     new JLabel("Total Bijdrage Herniewbare energie"),
                   /* Test : Leaf of type 'String' mixed with leaves of type 'JLabel'.
                                     "Total Opties : French and Dutch",
                                     "<html>Total Bijdrage <font color=red>WarmteKrachtKoppeling</font></html>",
                                     TotalDistrNetBeh1.toPlainString() + "Test1",
                                     new JLabel("<html>Total <font color=blue>Test2</font></html>")
            };In the displayed tree, rows with JPanel appear like this :
    javax.swing.JLabel[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=8388608,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,horizontalAlignment=LEADING,horizontalTextPosition=TRAILING,iconTextGap=4,labelFor=,text= 2.22,verticalAlignment=CENTER,verticalTextPosition=CENTER]
    <b>instead of simply " 2.22"</b>, as if there is a hiden (java.lang.String) casting. Why ?
    Nevertheless, the 'nodeSpecifier' argument in
            else
              child = new DefaultMutableTreeNode(nodeSpecifier); // Leafis casted to (javax.swing.JLabel)
    and 'child' and 'node' - both of 'Object' type - seem to be casted to (javax.swing.tree.DefaultMutableTreeNode)
    For memo :
        private DefaultMutableTreeNode constructHi�rarch(Object[] hi�rarchie)
        { DefaultMutableTreeNode node = new DefaultMutableTreeNode(hi�rarchie[0]);
          DefaultMutableTreeNode child;
          for(int i=1; i<hi�rarchie.length; i++)
          { Object nodeSpecifier = hi�rarchie;
    if (nodeSpecifier instanceof Object[]) // Node with children
    // Re-entering the function
    child = constructHi�rarch((Object[])nodeSpecifier);
    else
    child = new DefaultMutableTreeNode(nodeSpecifier); // Leaf
    node.add(child);
    return(node);
    Is it "DefaultMutableTreeNode(nodeSpecifier)" or "add(child)" that cannot operate properly with a argument of type 'JLabel' ?
    How to solve it ?
    Sorry, I'm a beginner in Java and Swing.
    Thanks in advance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Learn to properly use a TreeCellRenderer
    You never need to add a Component to a JTree, ie JLabel. You add the data, like a String, and then render the component you want to appear. Already, the String you have in your JTree are being rendered using JLabels, with a White Background. Hence, you need to provide a custom renderer that allows you to display different coloured rows depending on your condition or requirements.
    Read a little more on the TreeCellRenderer here: http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html
    ICE

  • StringBuffer and memory issue

    I am having trouble. I have a fairly large string buffer that I use instead of a file. The String Buffer can grow to 5-10 MB.
    When it grows, it seems that the memory of the JVM basically doubles each time.
    To grow the string buffer, I append to it each time, and I have tried making its initial size 1-2 mb for testing purposes.
    Is there some way to prevent the jvm from growing it's memory by 2 X each time? It seems wasteful, and when many users are logged in, 10 mb per 10 users gets to be a lot. Please advise??

    A StringBuffer will indeed double the storage it uses every time an overflow occurs. Given that it has no idea how large its contents will ultimately be, doubling its size on overflow is statistically the best possible approach.
    Seems to me, by choosing a StringBuffer instead of a file, you have considered the memory/speed trade-off and chosen higher speed, higher memory instead of lower speed, lower memory. And isn't it true that the issue is mostly that you are using multi-megabytes of memory, rather than that more megabytes of memory are potentially being wasted? If you are only concerned about the extra allocation that StringBuffer makes, you could call its setLength() method to clean up the waste after it reaches its maximum size.

  • StringBuffer and PreparedStatement

    Does anyone know why prepared statements don't update ? fields when you provide the preparedstatement with a query that is a stringbuffer?
    i.e.
    StringBuffer query = new StringBuffer(500);
    query.append("SELECT * from Customer WHERE CustId = ?");
        try{
                          pstmt = conn.prepareStatement(
                               query.toString()
                    pstmt.setInt(1, 2);
                    result = pstmt.executeQuery();

    Why are you doing this?
    StringBuffer query = new StringBuffer(500);I am doing this before i have to dynmically manipulate the query, i have an array which i have to loop around and keep adding to the query till i get to the end. I cannot do this by simply specifiying the query inside the prepared statmenet paramaeter. The question mark parameters have nothing to do with adding to the query, it works fine if i specify the actual fields CustID = 1; instead of CustID = ?;
    SO my actual point was simply:
    I want to following query inside a string buffer where i can specifiy the paramaeters at a later stage using setInt, setString etc.
    SELECT * from Customer WHERE CustId = ?
    System.out.println(query.toString()); gives:
    SELECT * from Customer WHERE CustId = ?Now the string buffer, I'm specifiy the query reference directly to the preparedsttement i.e. this would be the same if i did conn.preparedStatment(SELECT * FROM CUSTOMER WHERE CustID = ?);
    try{
                          pstmt = conn.prepareStatement(
                               query.toString()
                     );After i use pstmt.setInt(1, 2);
    i get:
    SELECT * from Customer WHERE CustId = ?when it should be:
    SELECT * from Customer WHERE CustId = 2

  • Storing data in Array or StringBuffer and then comparing it to a string

    I want to store some data in a list or an Array (but apparently an Array only holds 10 items?) and then I want to be able to check if myString is equal to any of the posts in the array/list.
    Or if I use a StringBuffer I want to check to see if myString is part of the StringBuffer?
    How do I do this?
    / Elin

    I want to store some data in a list or an Array (but
    apparently an Array only holds 10 items?)Uh, no. Arrays can (theoretically) contain Integer.MAX_VALUE elements.
    and then I want to be able to check if myString is equal to any
    of the posts in the array/list.Don't confuse String's equals() method with the equality operator '=='. The == operator checks that two references refer to the same object. If you want to compare the contents of Strings (whether two strings contain the same character sequence), use equals(), e.g. if (str1.equals(str2))...
    Example:String s1 = "foo";
    String s2 = new String("foo");
    System.out.println("s1 == s2: " + (s1 == s2)); // false
    System.out.println("s1.equals(s2): " + (s1.equals(s2))); // trueFor more information, check out Comparison operators: equals() versus ==
    Or if I use a StringBuffer I want to check to see if
    myString is part of the StringBuffer?See above discussion on .equals().
    How do I do this?
    Here are some other resources to help you get started with Java.
    The Java&#153; Tutorial - A practical guide for programmers
    Essentials, Part 1, Lesson 1: Compiling & Running a Simple Program
    New to Java Center
    How To Think Like A Computer Scientist
    Introduction to Computer Science using Java
    The Java Developers Almanac 1.4
    JavaRanch: a friendly place for Java greenhorns
    jGuru
    Bruce Eckel's Thinking in Java
    Joshua Bloch's Effective Java
    Bert Bates and Kathy Sierra's Head First Java

  • Parse lines out of a StringBuffer and/or InputStream

    I am loading and parsing a ~40MB text file. I am retrieving this file using the JCraft JSch SFTP library. This has given me no problems so far.
    Since I need to process this file line by line, my first approach was to read a character at a time off the InputStream provided by the SFTP library, collect characters until a new line was reached, then parse the line. This proved to be extremely slow. Now I'm pulling 1024 characters at a time into a byte[] from the stream and pushing that array into a StringBuffer until the end of the stream has been reached. It has sped up considerably, but now I don't know what the best way would be to process the buffer.
    What would be the best way to split off and process every line of this file? It seems redundant to pull the whole thing into a string buffer then parse it again by using charAt() and substring() to find and chop off lines. Reading character by character from the stream works in theory but is much too slow. Trying to parse the byte[] with fragments of lines is impractical and error prone.
    Memory is not an issue since it is running on a dedicated batch server, but speed is important.
    Thank you.

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    public class ReadLines {
        public static void readLinesFromInputStream(InputStream is)
             throws IOException {
         BufferedReader reader = new BufferedReader(new InputStreamReader(is),
              1024 * 1024);
         String line;
         while ((line = reader.readLine()) != null) {
             System.out.println(line);
    }Piet

  • Heavyweight object of an Icon and JLabel

    Hi there,
    I would like to know how can I create a heavyweight object that has a JLabel and an Icon and then add it to a JFrame. this heavyweight object would be something like this
    public class TestObject extends JPanel
    ..public TestObject( String LabelName )
    ....theLabel = new JLabel( LabelName );
    ....add( theIcon ); // I cant add the Icon here, because it's not a Component
    ....add( theLabel );
    ..private JLabel theLabel;
    ..private Icon theIcon = new ImageIcon( "littleIcon.gif" );
    Thanks,
    Andre

    Using the following class I could draw a JLabel that has an ImageIcon, but it doesn't matter what the value of the horizontalAlignment ( LEFT, CENTER, RIGHT, LEADING or TRAILING ) the icon was always at the left side and the string at the right. Is there a way to put the Icon on the top and the String at the button of the Label?
    public class TestObject extends JPanel
    public TestObjectent( String LabelName )
    theIcon = new ImageIcon( "littleIcon.gif" );
    theLabel = new JLabel( LabelName theIcon, SwingConstants.TRAILING );
    add( theLabel );
    private Icon theIcon;
    private JLabel theLabel;
    Thanks,
    Andre

  • StringBuffer and HashSet

    I've been using a HashSet to clear a String[] from duplicates. In the name of optimization I decided to use StringBuffer instead. This, however, made the removing of dublicates not possible. My question is obviously why, but also, is there a significant performance increase in using StringBuffer instead of string in the code below?
    String[] getID() {
          StringBuffer idNr[]; //was string before...
          idNr = getDirectory(); //returns  a StringBuffer[] with values
          int underScoreStart;
          int underScoreEnd;
          for (int i = 0; i < idNr.length; i++) {
             underScoreStart = idNr.indexOf(dataSeparetor) + 1;
    underScoreEnd = idNr[i].lastIndexOf(dataSeparetor);
    idNr[i] = new StringBuffer(idNr[i].substring( underScoreStart, underScoreEnd));
    java.util.HashSet sortSet = new java.util.HashSet();
    for (int i=0; i <idNr.length; i++) {
    sortSet.add(idNr[i]);
    StringBuffer[] array; // was string before
    int arrayIndex = 0;
    array = new StringBuffer[sortSet.size()];
    Iterator i = sortSet.iterator();
    while(i.hasNext()) {
    array[arrayIndex++] = (StringBuffer)i.next();
    System.out.println(array[arrayIndex-1]);
    StringBuffer tmp; //was string before
    for(int j = 0; j < array.length; j++){                           
    for (int l =0; l < (int)array.length -1; l++) {
    if(Integer.valueOf(array[l].toString()).intValue()>Integer.valueOf(array[j].toString()).intValue()) {
    tmp = array[l];
    array[l] = array[l+1];
    array[l+1] = tmp;
    String returnString[] = new String[array.length];
    for (int l=0; l < returnString.length; l++)
    returnString[l] = array[l].toString();
    return returnString;

    Thanx for you reply. I have gone back to using String
    when copying to the hashset and I have also replaced
    my own sorting function with Arrays.sort... The code
    looks as below now.
    Why is there a performance loss when using string
    buffer in the places I've indicated?Mainly because in a number of places String objects are created anyway and then you create StringBuffers copying the content of the String. If these StringBuffers are not used for editing their content then they are wasted space (in addition if you then need to use their String representation you've created yet another String object of the same content again). You also create many array objects which are abandoned - you can reduce this somewhat.
    Here's what I think is a tidier solution returning a List of String objects rather than an array though the array is still trivial.
    List getId() {
      String[] directory = getDirectory();
      Map workingMap = new HashMap();
      // Populate the map with the integer representations and String representations
      for(int count = 0; count < directory.length; count++) {
        int start = directory[count].indexOf(DATA_SEPARATOR) + 1;
        int end = directory[count].lastIndexOf(DATA_SEPARATOR);
        String s = directory[count].substring(start,end);
        Integer i = new Integer(s);
        workingMap.put(i,s);
      // Now we'll sort the keys and extract the values from the Map in order
      List list = new ArrayList(workingMap.keySet());
      Collections.sort(list);
      List results = new ArrayList(list.size());
      for(Iterator iterator = list.iterator(); iterator.hasNext(); ) {
        results.add(workingMap.get(iterator.next()));
      return results;
    }Personally I'd simply return a list of Integer objects and convert back to String only if necessary. In which case the code is very simple.
    List getId() {
      String[] directory = getDirectory();
      Set workingSet = new HashSet();
      for(int count = 0; count < directory.length; count++) {
        int start = directory[count].indexOf(DATA_SEPARATOR) + 1;
        int end = directory[count].lastIndexOf(DATA_SEPARATOR);
        Integer i = new Integer(directory[count].substring(start,end));
        workingSet.add(i);
      List results = new ArrayList(workingSet);
      Collections.sort(results);
      return results;
    }NB: Yes I know SortedMap is available... yet another way to skin a cat.
    Hope this helps
    PS: Don't forget those Dukes...
    Talden

  • StringBuffer and .equals()

    this is my test codes:
    public class Testing
         public static void main(String arg[])
              StringBuffer sb1 = new StringBuffer("test");
              StringBuffer sb2 = new StringBuffer("test");
              if (sb1.equals(sb2))
                   System.out.println("1");
                    System.out.println("End");
    }At runtime, the program only prints out End, without the number 1.
    My question is shouldn't the if-statement is equal to true?
    Doesnt .equals() method compare the content of one object to another object?
    thanks for any explanation
    daffy

    String is deliberately immutable (a value object). This means you can pass it around and share it as a data member in many classes without the danger that one class might change its value and therefore surprise all the other classes sharing it. IOW, you can treat it much like a basic type. StringBuffer is class for the efficient manipulation of String contents. It is mutable, and not really intended to be 'passed around' (i.e. made part of a interface, declared as an argument or return type in a non-private method) or shared by classes. In general, a String is passed to a method, manipulated via StringBuffer, then returned as a new String.

  • StringBuffer and CharBuffer

    Hello,
    I just stumled across some weird behaviour. It seems to be impossible to directly create a StringBuffer from a CharBuffer.
    Consider the following code:
    FileReader reader = new FileReader(fileName);
    CharBuffer chars = CharBuffer.allocate((int) fileSize);
    // read complete file
    while(reader.read(chars) != 0);
    reader.close();
    StringBuffer sb = new StringBuffer(chars);This will result in an empty StringBuffer. The reason for this is that StringBuffer uses CharSequence.length() to determine the length of the CharBuffer. However, CharBuffer implements the length method so that it returns the number of remaining bytes, not the bytes already written to the buffer!!! In the example above, the remaining bytes are 0. A work around for this problem is to call
    chars.position(0);before creating the StringBuffer. While this is would work in this case, it might not always be a solution.
    Is this a broken behaviour on behalf of CharBuffer? I mean it implements the CharSequence interface and thus should also behave like a CharSequence. IMHO, the CharBuffer implementation of the length method plainly contradicts the defintion of CharSequence.length().
    Any comments?
    Thank you very much
    draoi

    FileReader reader = new FileReader(fileName);
    CharBuffer chars = CharBuffer.allocate((int)
    fileSize);
    // read complete file
    while(reader.read(chars) != 0);
    reader.close();
    StringBuffer sb = new StringBuffer(chars);This will result in an empty StringBuffer. The reasonHow about using chars.flip() just before creating the StringBuffer. Seems to work for me (but used put instead of read).
    Harald.
    BioMed Information Extraction: http://www.ebi.ac.uk/Rebholz-srv/whatizit

  • StringBuffer and ObjectOutputStream

    I have a question concerning writting a StringBuffer object to a file using ObjectOutputStream (The code snippet is below..). I am merging 2 files together(relatively small files 300 lines). I am storing the merge portion of the 2 files in a StringBuffer. After the merge is done I write this StringBuffer to a file. See code below...
    private void writeToFile()
    try
    ObjectOutputStream outFile = new ObjectOutputStream(new FileOutputStream("Merged.csv"));
    outFile.writeObject(outBuffer.toString()); //outBuffer is a class member
    outFile.flush();
    catch(Exception e)
    e.printStackTrace();
    }//catch
    }//writeToFile
    PROBLEM:
    A snippet of the orginal file that I am reading in:
    Name,GUID,Initial Date,Initial Time,Initial Audit,Last....
    The same line of the merged file that I am writting out:
    ��2openboxs|6openboxes| 'Name,GUID,Initial Date,Initial Time,Initial...
    It is writing out what appears to be junk at the beginning of the file. I did not do any merge at this point. When I print this first line out to the console the junk does not show up?
    If anybody has run in this problem or know what is causing this, then your input would be greatly appreciated.
    Thanks.

    ObjectOuputStream writes a serialized Object to a file. The 'junk' you are seeing is information about the type of object and other things necessary to deserialize the object. You should try reading the API documentation for a class before you start using it. Use the right tool for the job.

  • StringBuffer and letter color

    hi I use
    StringBuffer Wsb = new StringBuffer();
    if (Type1.contains("on"))
    Wsb.append("C1");
    if (Type2.contains("on")){
    if(Wsb.capacity()!=0)
    Wsb.append(",C2");
    else
    Wsb.append("C2");
    } how can I set the color of letter C1, C2 to red, when I use Wsb.append(" <font color="red"> "); I get error

    HJava wrote:
    how can I set the color of letter C1, C2 to red, when I use Wsb.append(" <font color="red"> "); I get errorNot quite sure what you're trying to do.
    If you append as you said, what the compiler sees is two strings with 'red' between them.
    You need to escape the inner quotes in order that they don't terminate the string, viz:
    Wsb.append(" <font color=\"red\"> ");However, even when you get it to work, Wsb will contain
    C1, C2 <font color="red">
    and, even assuming that your spitting it out to some HTML-aware component, that still won't make C1 and C2 come out red.
    Winston

  • Unicode characters and JLabel

    Is it possible to display a Unicode character on a JLabel?

    I am not sure it works but you can create a JLabel as
    JLabel aLabel = new JLabel("<html>some characters</htm/>")
    </code]
    and if you know creating html pages with special characters or symbls then you can try it.                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for

  • How do i know if my lost ipod touch has been reset?

    I have lost it a couple of days ago and am using FIND MY IPHONE and it says that my iPod is offline. Does this mean it has been reset or it is still out there?

  • Deploy Error for Web Dynpro

    I have got the error message on Deploying the project of web dynpro, they are: Deployment aborted 2006年7月6日 上午10:21:13 /userOut/deploy (com.sap.ide.eclipse.sdm.threading.DeployThreadManager) [Thread[Deploy Thread,5,main]] ERROR: [002]Deployment abort

  • Moving the player to the mouse position.

    I have a question about moving and animated player symbol to the mouse location on a MouseDown event. Right now I have it set up to do an easing so that I can control how fast the player moves to the location. Problem is that it is done with easing.

  • Moving part of a catalog to network drive.

    I need some good advice for a catalog of 13k+ photos that I'm trying to clean up. I'm using Elements 7, I have purchased Elements 11, and am planning to install it soon. Part of my photos are physically located on my hard drive, and part are on a net

  • Group output data with cftable

    I can group data with breaks between each group with the following syntax: <!--------------------------------------------------------------------------------------> <cfoutput query="GetResults" group="site" > <table border="0" cellspacing="0" cellpad