Backspace character

Hi,
i have problems to print backspace character in the text file.It always print rectangular type box.
just try this code...
import java.util.Vector;
public class Test
Test test = new Test();
public Test()
public static void main(String[] args)
System.out.print("Hello");
System.out.print('\b');
System.out.print("World");
test.writeToFile();
private void writeToFile()
try
java.io.FileOutputStream l_objWrt = new java.io.FileOutputStream("d:\\test.txt",true);
java.io.PrintStream l_objPrn = new java.io.PrintStream(l_objWrt);l_objPrn.print("abcd");
l_objPrn.print('\b');
l_objPrn.print("xyz");
l_objPrn.close();
l_objWrt.close();
catch(Exception e)
}

Why wouldn't it print a rectangular box? The text editor prints a rectangular box because there isn't a character for a backspace its an escape sequence like a tab or a new line. If you look at that same file in a hex editor you will see the hexadecimal value of a backspace so it is there. But your text editor, or any text editor for that matter, dosn't have anything to represent a backspace on screen so a black box is used.

Similar Messages

  • How do you output a backspace character?

    Hi there,
    I'm creating a VI in which I need to output the backspace character to a TCP output. I want the cursor on the terminal to actually back up one character so I'm assuming I need to output the ASCII backspace character. However, I don't know how to do this. I've tried sending out \b but instead of a backspace, the character string is just \b.
    Is there a way I can convert an integer to an ASCII character? Or is there another way to do this? Thanks a lot!!
    -Mike

    If you want to send a \b, then right click on the control and select '\' Codes Display and then enter \b. Otherwise, the characters will be no interpreted correctly. Another way to do it is turn on Hex Display and enter 08.

  • Function to replace/delete specific character(s) in a string

    Hi, experienced CVI guys,
    Are there some functions shipped with CVI to replace or delete specific characters in a string?
    For example, I want to replace all \/|- with an empty string, or to delete them. What can I do?  Loops are too complex.
    Original string:
    Erasing Device...
    \|/- \ \ \\|/-\|/ \
    Report
    07-Sep-2010, 08:04:55
    Result I want is
    Erasing Device...
    Report
    07-Sep-2010, 08:04:55
    Thanks.
    Solved!
    Go to Solution.

    labc:
    How generic do you want to make your filter?
    For our discussion, I'll call your series of characters a text spinner.  I'm assuming the number of characters in it may vary, but that the pattern is consistent in the respect: the spinner is made up of characters like \ / | -, each followed by the ASCII backspace (char) 8.  (That's 8 cast as a character, which is not the same as '8'.)  In your sample spinner pattern, every occurrence of the ASCII backspace is preceded by one of the spinner characters.  Let's assume that this pattern is constant.
    So what I'd do is search through your input string (yes, using a loop) and copy the input string byte by byte to an output string.  If you find an ASCII backspace in the input string, skip it, and overwrite the last character in the output string (which is one of the spinner characters) with the next character in the input string.
    Yes, you are using a loop, but it's not too complex.
    Here's the whole loop, written as a function.
    // filterSpinner function to strip the text spinner characters out of a string.
    // The text spinner is made up of \ / | - characters separated by (char) 8 (ASCII backspace)
    int filterSpinner(char *inputString, char *outputString)
     int inputPtr, outputPtr = 0;
     // walk though the input string
     for (inputPtr = 0; inputPtr < strlen(inputString); inputPtr++, outputPtr++)
      // search for the ASCII backspace character that's part of the spinner
      if (inputString[inputPtr] == 8)
       // if the ASCII backspace is found,
       inputPtr++;  // increment the inputString pointer to skip the backspace
       outputPtr--; // decrement the outputString pointer to overwrite
           // the spinner character that preceded the backspace
      outputString[outputPtr] = inputString[inputPtr];
     outputString[outputPtr] = '\0';
     return 0;
    You'll also find an attached CVI program which uses it on your sample string.
    Attachments:
    FilterSpinner1.zip ‏5 KB

  • Key Event refusal to recognise backspace

    Hello,
    I have used a key listener to ensure that the characters entered into a text area are numbers only. to do this i have an if statement to check that the event character is not a number, and is not a delete or backspace
    However when run, the backspace characters are not getting caught. print outs show that a blank char is written when e.getKeyChar() is called, 0 is written when e.getKeyCode() is called, and Unknown keyCode: 0x0 is written when e.getKeyText(e.getKeyCode()) is called.
    Is there any other way to check for a backspace character?
    Thanks for your help! :)

    Fillis52 wrote:
    ..Is there any other way to check for a backspace character?There is of course, the right way. This code works here.
    import java.awt.event.*;
    import javax.swing.*;
    class TestBackSpace {
        public static void main(String[] args) {
            JTextField tf = new JTextField();
            tf.addKeyListener( new KeyListener() {
                public void keyPressed(KeyEvent ke) {
                    System.out.println( ke.getKeyCode()==KeyEvent.VK_BACK_SPACE );
                public void keyReleased(KeyEvent ke) {}
                public void keyTyped(KeyEvent ke) {}
            JOptionPane.showMessageDialog(null, tf);
    Thanks for your help! :)You might look to post an SSCCE (http://pscode.org/sscce.html) in future, then you will likely get more help.

  • File sharing: possible to warn second user of a file that it is already open?

    [I hope this forum is the best place for my question.]
    I run a small business: a medical practice. I use a Mac Mini to store all my documents, and we use two iMacs to access the documents through File Sharing. I do not run OSX Lion Server. All machines have OSX 10.7.5.
    I have a Numbers spreadsheet on the Mac Mini that is frequently opened and modified by the receptionist on one iMac, but also occasionally opened and modified by the doctor on the other iMac. (The vast majority of other files never need to be opened by more than one user.) Occasionally, the Numbers file will be opened by both users at the same time. If one user modifies the file, when s/he tries to close the file, a dialog pops up warning that there are two versions, and providing the choice to Revert or Duplicate & Save. This means a choice between losing changes, or subsequently checking two documents for differences.
    Note that it isn't possible to simply call out, "Hey, have you got that spreadsheet open?" when the doctor is seeing a patient.
    Also note that privacy is an issue, as the spreadsheet contains numerous patient names.
    Is there a way to: (a) Warn the second user opening the file that it is already open? Or (b) Make the file read-only when a second user tries to open it? (c) Inform the second user that the file is in use, and they can't open it at all. (There may be other solutions that I can't think of.)
    I am open to all ideas. I have tried dabbling with AppleScript, but can't find a solution with my emerging AppleScript skills. I have been trying to find out if installing OSX Lion Server on the Mac Mini would help, but I can't find the answer online. (I would have to pay someone to install OSX Lion Server, as I have medical software installed that may or may not fit well with Server.)
    Thanks in advance for any help.
    Peter

    hmm, then would there be any way to reproduce the effect of the 'delete' or 'backspace' keys? If I'm right, I think there was an ASCII code for the backspace character... Would it be possible to insert it to get a character deleted!? :/
    I really need to find a way to do all of these operations on a text file because I think it wouldn't be a good idea to completely re-write 30Mb+ large files each time some data has to be modified :P

  • Network Accounts used on Lion computers no longer work with Snow Leopard computers.

    I am having issues with my network users who have once used a computer with Lion on it joined to the network then going to use a Snow Leopard workstation and Google Chrome and Safari crash randomly either at the first 30 seconds or typing a space or backspace character.

    I am also facing this situation with a 2007 2 GHz Intel Core 2 Duo Mac Mini that is running OS 10.7.4 Lion, which is not upgradable to Mountain Lion because it requires 64 bit processsing, while the Mini is limited to 32 bit. Why is Pages suddenly crippled? I've never seen anything like this. Somehow, Pages was upgraded to 4.2 and now it no longer runs even though I have upgraded to your last latest OS before Mountain Lion. What gives, Apple? I've spent thousands on your products over the years, from an Apple IIgs, IIci, Mac 6100, 7100, iMac, and on through my two iPad and five iPhones. We customers deserve an explanation, not the silent treatment. Fix this.

  • Invalid char in text.

    Hi all,
    I just recieved this nice error when loading a file:
    Error: oracle.xml.parser.v2.XMLParseException: Invalid char in text.
    Its was cause by a backspace character (^H or /b or 08). Shouldn't this be supported in utf-8???

    Hi all!
    I seem to be sailing in a similar boat like Mr. James!
    I get an error like this,
    <Line 98278, Column -13440>: XML-0221: (Fatal Error) Invalid char in text.
    oracle.xml.sql.OracleXMLSQLException: Invalid char in text.
    It is caused by a carriage return character.
    Help Anyone?
    Regards,
    Sunil.

  • Problem matching JTextField input to an item in a JList box

    Hello,
    I am trying to read the user's input in a text field and take the user to a match in a list box located underneath the textfield. To do that I have implemented the following code:
    m_pathwayNameTextField.addKeyListener(new KeyAdapter() {
    public void keyTyped(KeyEvent e) {
    m_pathwayNameTextField_KeyTyped(e);
    private void m_pathwayNameTextField_KeyTyped(KeyEvent e) {
    if (e.getID() == KeyEvent.KEY_TYPED) {
    String prefix = m_pathwayNameTextField.getText();
    char c = e.getKeyChar();
    if (e.getKeyChar() >= KeyEvent.VK_SPACE && e.getKeyCode() < 127) {
    prefix = prefix + e.getKeyChar();
    int position = m_pathwayNamesList.getNextMatch(prefix, 0,
    Position.Bias.Forward);
    if (position != -1) {
    m_pathwayNamesList.ensureIndexIsVisible(position);
    Although the above kind of works, it still has some problems. The first is that if I press a "backspace" character, it won't try to match any results. Also, if I highlight the whole text in the textfield and press a letter, it won't attempt to match either. The reason for the later is that the textfield at that time is not blank and so prefix becomes the textfield plus the newly entered letter, whereas it should be the newly entered letter.
    Any help on this is highly appreciated.
    Thanks.

    The best way to do this is to use a DocumentListener instead of a KeyListener. When the DocumentEvent is fired the document has already been updated and you can just use getText() to get the contents of the Document. No need to play around with backspace characters.

  • Regular expressions in Workshop 8.1

    Hello,
    I'm posting this question here because I don't see a "jdk" subcategory in this
    newsgroup and it might be problem peculiar to Workshop.
    I'm trying to use the Pattern and Matcher classes in java.util.regex (JDK 1.4.2)
    in BEA Workshop 8.1, but I'm getting "ERROR: Unknown escape code" (red squiggly
    line appears under the regex and this message is the screen tip) whenever I try
    to use the backslash to escape a special character in the Pattern.compile() and
    the Pattern.matches() methods.
    For example, it doesn't allow "\d" to mean "any digit". For this particular one,
    I can get around the problem by specifying "[0-9]", but in the case of the period
    character, I'm stuck. I cannot use "\." However, the JDK API doc (http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html)
    says the backslash is to be used for this purpose, if I'm reading it correctly.
    Is this a problem with Workshop, and is there a workaround? I need to specify
    that I require one and exactly one period.
    Any help would be most appreciated!
    Thanks.

    Yes, I had read the Java doc, but I guess I hadn't fully understood it. Now I
    do! Thanks!!
    David
    Josh Eckels <[email protected]> wrote:
    This isn't particular to Workshop, but you'll need to use two
    backslashes in your source code. Inside a string, backslash is used to
    escape the next character so that you can enter special characters like
    newlines ('\n'), tabs ('\t'), etc.
    So, in order to enter a backslash character into your string, you need
    to escape it, like '\\'.
    There's a small section on this in the java.util.regex.Pattern JavaDoc,
    under the "Backslashes, escapes, and quoting" header:
    Backslashes within string literals in Java source code are interpreted
    as required by the Java Language Specification as either Unicode escapes
    or other character escapes. It is therefore necessary to double
    backslashes in string literals that represent regular expressions to
    protect them from interpretation by the Java bytecode compiler. The
    string literal "\b", for example, matches a single backspace character
    when interpreted as a regular expression, while "\\b" matches a word
    boundary. The string literal "\(hello\)" is illegal and leads to a
    compile-time error; in order to match the string (hello) the string
    literal "\\(hello\\)" must be used.
    Josh
    David Chang wrote:
    Hello,
    I'm posting this question here because I don't see a "jdk" subcategoryin this
    newsgroup and it might be problem peculiar to Workshop.
    I'm trying to use the Pattern and Matcher classes in java.util.regex(JDK 1.4.2)
    in BEA Workshop 8.1, but I'm getting "ERROR: Unknown escape code" (redsquiggly
    line appears under the regex and this message is the screen tip) wheneverI try
    to use the backslash to escape a special character in the Pattern.compile()and
    the Pattern.matches() methods.
    For example, it doesn't allow "\d" to mean "any digit". For this particularone,
    I can get around the problem by specifying "[0-9]", but in the caseof the period
    character, I'm stuck. I cannot use "\." However, the JDK API doc
    (http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html)
    says the backslash is to be used for this purpose, if I'm reading itcorrectly.
    Is this a problem with Workshop, and is there a workaround? I needto specify
    that I require one and exactly one period.
    Any help would be most appreciated!
    Thanks.

  • Problem: sqldeveloper 1.5 key bindings in mac os x

    Hi -
    I just installed the new sqldeveloper (1.5.0.53.38) on Mac OS X Leopard, and when I try to edit sql queries in the worksheet, I'm finding that many keys don't work. For example, the spacebar and delete keys do nothing.
    I tried loading various different accelerator presets:
    - after loading "Default MacOS X" set, neither space nor delete keys do anything
    - after loading "Default", "Classic" or "Brief" sets, the spacebar works, but not delete
    I tried to fix this by changing the accelerators through the Preferences UI, but I couldn't figure out how to assign the 'backspace' key to the 'delete-previous' accelerator (since it doesn't seem possible to type the actual backspace character in the keystroke box...). I was able to fix the delete key by editing settings.xml by hand, changing this:
    <Item class="oracle.javatools.util.Pair">
    <first class="java.lang.String">delete-previous</first>
    <second class="oracle.ide.keyboard.KeyStrokes">
    <data>
    <Item class="javax.swing.KeyStroke">[0]</Item>
    </data>
    </second>
    </Item>
    to this:
    <Item class="oracle.javatools.util.Pair">
    <first class="java.lang.String">delete-previous</first>
    <second class="oracle.ide.keyboard.KeyStrokes">
    <data>
    <Item class="javax.swing.KeyStroke">[8]</Item>
    </data>
    </second>
    </Item>
    I was able to get the spacebar to work again by removing the association between the spacebar key and the completion-insight accelerator, using the Preferences UI.
    So, my questions are:
    - Do I have some weird setup where my delete key is [8] instead of [0]? I'm trying to tell if this is a problem with my environment or with the settings that are shipped with the product.
    - If it's the latter, could the default MacOS X accelerator settings be updated? I seem to remember this same problem happening the last couple of times I installed a new version of SQL Developer.
    Let me know if there's any other information I could provide that would be useful.
    Thanks!

    Another problem I found with the MacOS X key bindings: the 6 key doesn't work!
    In the config that ships with SQL Developer, I found this:
    <Item class="oracle.javatools.util.Pair">
    <first class="java.lang.String">DOCUMENT_6_CMD_ID</first>
    <second class="oracle.ide.keyboard.KeyStrokes">
    <data>
    <Item class="javax.swing.KeyStroke">6</Item>
    </data>
    </second>
    </Item>
    which should be:
    <Item class="oracle.javatools.util.Pair">
    <first class="java.lang.String">DOCUMENT_6_CMD_ID</first>
    <second class="oracle.ide.keyboard.KeyStrokes">
    <data>
    <Item class="javax.swing.KeyStroke">meta 6</Item>
    </data>
    </second>
    </Item>

  • How to clear the screen in the command prompt?

    Hello Everyone,
    I was wondering how we can clear the screen in the command prompt in Java. I remember we can do this in C by writing system("cls");
    What is the best IDE for writing Java programs. Is the NetBeans IDE good? Thank you very much.

    I was wondering how we can clear the screen in the
    command prompt in Java. I remember we can do this in
    C by writing system("cls");I guess there's no Java way of doing that because it's a function of the shell you're calling. If you try to use Runtime.exec on cls, it starts yet another shell, clears that, and closes it again, so it has no effect on your output.
    You could try using the '\b' backspace character, if that helps.
    What is the best IDE for writing Java programs. Is
    the NetBeans IDE good? Thank you very much.By the way you're asking this question, the answer will be almost certainly "none". If you want to, you can search this board for the few million times this question was asked before, pick all IDEs suggested there and use the one you're most comfortable with.

  • Make smart playlists in iTunes?

    Is it possible to do this? I have a pile of unsmart PLs that I want to convert to smart ones. I've got a scpt going that basically does the job, but although I say
    make user playlist with properties {smart: true, name:PLname}
    they always come out unsmart.
    I note that the iTunes dictionary says smart is r/o, but surely for a new PL I'm just making, I can say smart:true ?

    In case anyone else wants to do what I did, here's the final form of my scpt. But it has a couple of bug workarounds, so it may not work beyond iTunes 8.1.1 (6). Good luck!
    (* Make smart PLs from unsmart Composer-based *)
    (* Doesn't test if unsmart PL name actually IS a composer contained in Music PL. Would take too long. *)
    (* - - - - - - - >>> !!!! TURN OFF AirPort !!!!! <<<- - - - - - - else you can get killed by e.g. Software Update *)
    tell application "iTunes"
    delay 3 -- Delay 3secs to get a chance to click the iT window after launching the scpt.
    set allPLs to (get every user playlist)
    repeat with thisPL in allPLs
    if name of thisPL is not "Music" then
    (* extract 1st word (surname) of unsmart PL name... *)
    if smart of thisPL is false then
    set comp to name of thisPL
    set comp to words of comp -- ludicrous - takes 4 operations to get word out of Unicode text
    set comp to (comp as string)
    ignoring hyphens
    set AppleScript's text item delimiters to " " --necessary for words
    set comp to word 1 of comp -- got 1st word at last
    end ignoring
    tell application "System Events" to tell process "iTunes"
    delay 0.5
    keystroke "n" using {option down, command down} ---- <---- <---- create New smart PL
    (* change Artist to Composer *)
    delay 0.5
    tell scroll area 1 of group 1 of window 1
    delay 0.5
    click pop up button 2
    delay 0.5
    click menu item "Composer" of menu 1 of pop up button 2 -- Change Artist to Composer
    delay 0.5
    keystroke comp & quote -- the quote stops iT auto-complete filling in the whole name etc. See ASCII below
    (*Cursor is still in TF1 of SA1 of G1 of W1, so keystroke comp works almost regardless of where we are*)
    end tell
    (* Change Random to Album *)
    delay 0.5
    click pop up button 1 of window 1
    delay 0.5
    click menu item "Album" of menu 1 of pop up button 1 of window 1
    (* as soon as you change above menu item, Checkbox 3 (to left of 25) gets set. Bug?
    Solution: Click Checkbox 3 of w1 later (below)
    It seems NOTHING can change the 25 to e.g. 999 (another bug?) *)
    (* Now we can complete the Composer *)
    delay 0.5
    keystroke (ASCII character 8) -- rubout the quot in the PL name with a Backspace character
    (* workaround the Limit to 25 checkbox bug *)
    delay 0.5
    click checkbox 3 of window 1 -- uncheck the "limit to 25"
    (* The above WILL DO THE REVERSE OF WHAT I WANT if they ever fix the bug above *)
    (* finish comp and close the New SPL window *)
    delay 0.5
    keystroke return
    (* Now we need a Return to finish the new SPL Name in the sidebar *)
    delay 1
    keystroke return
    end tell
    end if
    end if
    end repeat
    end tell
    beep 3 -- Say we're all done
    tell application "Script Editor" -- TEST
    activate
    end tell*)
    As I said, Good luck!
    David Whitford

  • Is there any class that makes it possible to modify the content of a file?

    I am looking for a class in the APIs (preferably) that would make it possible to open up an existing file, and delete specific characters, insert characters at specific places and do things like that... Is there any such class?

    hmm, then would there be any way to reproduce the effect of the 'delete' or 'backspace' keys? If I'm right, I think there was an ASCII code for the backspace character... Would it be possible to insert it to get a character deleted!? :/
    I really need to find a way to do all of these operations on a text file because I think it wouldn't be a good idea to completely re-write 30Mb+ large files each time some data has to be modified :P

  • Help with the keyboard

    Hi! My case is very simple, and it is so simple that i didn't find any question equal to mine.
     How I do the backspace?

    I don't quite understand what you are trying to accomplish. You said you're "doing a keyboard". What exactly does that mean? Are you trying to have a front panel that looks like a keyboard? Your code seems to imply that you want to have some sort of visual indication of something like keys being pressed, but the keys come from some array, or some other source. Please clarify this. What is the purpose of this? Is this related to your other question?
    Comments regarding the code:
    If you have an array as the source of data then you should use auto-indexing on the for-loop rather than wiring a "magic number" to the N terminal and using Index Array. Please read the LabVIEW Help on auto-indexing loops. 
    Writing a backspace character to a string indicator isn't the same as actually pressing the backspace key on the keyboard. You're actually writing a value to the string, not sending keystrokes, which is something different. 
    I am assuming the comparisons at the bottom were just for debugging. However, it should be pointed out that the sequence frame is unnecessary - think dataflow. Also, you do not have the outputs of the comparisons wired to the Boolean indicators. 
    To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.

  • Spotlight Refresh Time?

    Is there a function in spotlight that causes it to repeat the search after a given period of time and if so is it controllable?
    I find that after a search is complete and the search window stabilizes it waits for some period of time and then repeats the search. In doing this, it clears the search window and starts filling it with the same data it had earlier.
    This becomes frustrating when the wait time is so short that I don't have time review the list of items - this happens frequently.
    Any suggestions on how to get a stable search window?
    G4 MDD, 17" Pb   Mac OS X (10.4.7)  

    Think a step machine; you have an on/off button, a
    button for training time setup, an emergency stop and
    a starting button.
    First of all you open the machine, then you set a
    training time and then you start your training.
    During your training you can see a time (for this
    reason I need a refresh every second).
    In the meantime you can pause your trainig, or
    stopping it, so I need (while displaying a count down
    time) to catch a stop / pause button.This sounds great for a GUI, but pretty bad for a console app.
    think of a console. You have one cursor. You're about to type what you want, when suddenly the timer refreshes and your cursor goes elsewhere. You can be sure that your input ends up all over the screen, in single chars. Which will happen often, as you update every second.
    And, as I already mentioned: you cannot "update" the console (short of of writing a backspace character and re-writing the last output). It's like trying to update what you wrote down with a ballpoint.

Maybe you are looking for

  • Can't get Airport to work on PowerMac G4-533, yet it's recognized...

    I have a PowerMac G4-533 machine with 256 Mb ram. I've tried installing an Airport card into the machine and cannot locate any wireless networks with Airport turned on. I even tried swapping Airport cards between this machine and my G3-600, and find

  • Printing in Mac OS X

    Hello all, I created a printable class that works in Windows and Linux, but for some reason will not work on Mac OS X. It either prints a blank page or throws a nasty exception: Exception in thread "Thread-0" java.lang.NullPointerException at javax.s

  • Vedo is messed up

    my vedeio words sre slanted have trouble reading the words veioo shakking at times most of the times when i'm watching moves

  • PackageMaker (Simple problem I'm sure)

    Hi everyone - Getting my feet wet playing around with PackageMaker, and there's one thing that doesn't make sense to me. How do you install to the "Users" directory without knowing the user's name? I can select a content piece in the left column, and

  • Stopping animations in a published project

    We have inserted an swf animation (created in Captivate) in to a slide and have also placed navigation buttons on the slide. If the viewer hits "next" before the animation has finished, then the animation continues to play right to the end of its tim