Converting a Text Document to ASCII

| Test Application
| Created by Aaron
| Last Updated 7th March 2008
import java.io.*;
import javax.swing.*;
class Test {
public static void main(String[] args) throws IOException {
     BufferedReader readSecretMessage = new BufferedReader(new FileReader("SecretMessage.txt"));
     JOptionPane.showMessageDialog(null, readSecretMessage.readLine());
     do {
     int ASCII= 98; // Example
     String yourString= ""+((char)ASCII);
     JOptionPane.showMessageDialog(null, yourString);
     while(readSecretMessage.read() != -1);
}     Heres my testing code so far... It's wrong i know! But i'm really stuck... I want to convert the txt document "SecretMessage.txt" to ASCII characters and shift the characters 13 places (so for example B will become O, etc)... Any tips and pointers? I know i'm essentially there...Any help appreciated.

TheMungo wrote:
Ok... No I don't.
          String foo = "abcde";
          for (int i = 0; i < foo.length(); i++)
          System.out.print((int) foo.charAt(i)+13);
          }How do I get back to characters after?As posted above:
Than you cast back with (char).But I don't think that will mean anything to you.
Lets break this down into smaller tasks. The first is to turn a char into a number. We can do this by something called a "cast". so:
char myChar = 'a';
int myCharAsAnInteger = (int)myChar;See the () bit, that "casts" the char into an integer.
The next task is to add an amount to the integer (and handle overflows and stuff, but we shall deal with that later). I'll let you do this part.
Finally we have to take a integer and make it a char again. Using what is shown above have a go at this.

Similar Messages

  • How to convert a Word document to text or html in an ABAP program

    Hi,
    At my client's site, for the recruitment system, they have the word processing system set to RTF, instead of SAP Script. This means that all the correspondence is in Word format. A standard SAP program takes the word letter, loads word, does the mail merge with the applicant's info and then sends the document to a printer.
    The program name is RPAPRT05. The program creates a document proxy (interface I_OI_DOCUMENT_PROXY) and manipulates the document using the methods of the interface.
    Now what we want to do is to instead of sending the document to a printer, we want to email the document contents to the applicant. But I don't know how to get the content from the Word document into text or html format so that I can make an email from it.
    I know I can send an email with the word document as an attachment, but we'd prefer not to do that.
    I would appreciate any help very much.
    Thanks

    Ok, here's what I ended up doing:
    First of, in order to call FM 'CONVERT_RTF_TO_ITF' you need the RTF document in a table with line length 156. The document is returned from FM 'DP_CREATE_URL' in a table with line length 132. So first I convert the table:
        Transform data table from 132 character lines to
        256 character lines
          LOOP AT data_table INTO dataline.
            IF newrow = 'X'.
            Add row to new table
              APPEND INITIAL LINE TO xdatatab ASSIGNING .
              newrow = space.
            ENDIF.
          Convert the raw line of old table to characters
            ASSIGN dataline TO .
          Check line lengths to determine how to add the
          next line of old table
            newlinelen = STRLEN( newline ).
            ADD addspaces TO newlinelen.
            linepos = linemax - newlinelen.
            IF linepos > datalen.
            Enough space available in new table line for all of old table line
              newline+newlinelen = oldline.
              oldlinelen = STRLEN( oldline ).
              addspaces = datalen - oldlinelen.
              CONTINUE.
            ELSE.
            Fill up new table line
              newline+newlinelen(linepos) = oldline(linepos).
              ASSIGN newline TO .
              newrow = 'X'.
            Save the remainder of old table to the new table line
              IF linepos < datalen.
                oldlinelen = STRLEN( oldline ).
                addspaces = datalen - oldlinelen.
                CLEAR newline.
                newline = oldline+linepos.
              ELSE.
                CLEAR newline.
              ENDIF.
            ENDIF.
          ENDLOOP.
        Write the last line to the table
          IF newrow = 'X'.
            APPEND INITIAL LINE TO xdatatab ASSIGNING .
    Next I call FM 'CONVERT_RTF_TO_ITF' to get the document in SAPScript format:
        Convert the RTF format to SAPScript
          CALL FUNCTION 'CONVERT_RTF_TO_ITF'
            EXPORTING
              header            = dochead
              x_datatab         = xdatatab
              x_size            = xsize
            IMPORTING
              with_tab_e        = withtab
            TABLES
              itf_lines         = itf_table
            EXCEPTIONS
              invalid_tabletype = 1
              missing_size      = 2
              OTHERS            = 4.
    This returns the document still containing the mail merge fields which needs to be filled in:
          LOOP AT itf_table INTO itf_line.
            WHILE itf_line CS '«'.
              startpos = sy-fdpos + 1.
              IF itf_line CS '»'.
                tokenlength = sy-fdpos - startpos.
              ENDIF.
              token = itf_line+startpos(tokenlength).
              REPLACE '_' IN token WITH '-'.
              ASSIGN (token) TO .
              ENDIF.
              MODIFY itf_table FROM itf_line.
            ENDWHILE.
          ENDLOOP.
    And finally I use FM 'CONVERT_ITF_TO_ASCII' to convert the SAPScript to text. I set the line lengths to 60, since that's a good length to format emails to.
        Convert document to 60 char wide ascii document for emailing
          CALL FUNCTION 'CONVERT_ITF_TO_ASCII'
            EXPORTING
              formatwidth       = 60
            IMPORTING
              c_datatab         = asciidoctab
              x_size            = documentsize
            TABLES
              itf_lines         = itf_table
            EXCEPTIONS
              invalid_tabletype = 1
              OTHERS            = 2.
    And then the text document gets passed to FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' as the email body.

  • I have upgraded to Pages 5.0.1 and now I cannot print or pass along "comments" in the text of a document. I previously was able to convert the Pages document, with comments, to a "Word" document so that others could view the edited text. How do I do that?

    I have upgraded to Pages 5.0.1 and now I cannot print or pass along "comments" in the text of a document. I previously was able to convert the Pages document, with comments, to a "Word" document so that others could view the edited text. How do I do that?

    When you installed Pages v5, it automatically moved the older Pages ’09 v4.3 into /Applications/iWork '09 folder. If you want normal comment interoperability, you are advised to resume using the older version of Pages. Newer, is certainly not better with Pages v5.

  • Loss of formatting when emailing a AW6 ASCIII Text document

    Background: I have taken an .xls email file from a PC user which I was able to open with icExcel. The .xls file was set up wrong---only two columns, surname in one and all other data (street address, city, state, zip, tel., email address) in another column. I created a spreadsheet file in icExcel AWorks6 and did a lot of cutting and pasting from the original file to create a true 7 column spreadsheet. I saved it as an ASCII Text document because my intent is to email it back to the PC user.
    Now the dilemma---I can take that ASCII Text document and reopen it in an AW6 spreadsheet or into a database on my computer, no problems. Everything is formatted correctly. When I email the .txt document as an attachment to myself (experimenting first before emailing it to the PC user) it opens up automatically as a word processing document with all the formatting gone. I sent it to another of my email addresses, it did not open up automatically but the attachment came across as an HTTP text unix document file. What is happening to the structure and column formatting when I email the .txt document. What am I doing wrong following putting it into ASCII Text? Help please!! CAB
    Mac mini Intel/iBook G3   Mac OS X (10.4.5)   Mac OSX (10.3.5) for iBook
    Mac mini Intel/iBook G3   Mac OS X (10.4.5)   Mac OSX (10.3.5) for iBook

    When you save an AppleWorks spreadsheet as text, you get a tab delimited file.
    Data in each cell is followed by a tab character, and a return character separates the rows of data.
    Your text file, opened into an AppleWorks WP document, should retain the tab characters, but will not display properly unless you have set tab stops in the ruler. AppleWorks defaults to a tab stop every half inch, and a tab character will push text to the next available stop. Variable length of data will cause data that should line up in the same column to be offset.
    You can check for the presence of tabs (and other invisible characters) by pressing command-; (semi colon). Pressing the same keys again toggles the display off.
    Try launching AppleWorks then specifying Spreadsheet as the document type when you open it using AW's Open dialogue (File > Open).
    If you are successful, then the file should be openable by the PC user, using Excel. Three other notes: Be sure you check the Send Windows friendly attachments box in Mail when attaching the file. Be sure you add the .txt extension to the file name AppleWorks does not automatically add it). Tell the Windows user that the file is a tab delimited text file.
    Regards,
    Barry

  • How to convert a Word Document to SAP SCript standard text.

    Hi team,
    Does any one know how to convert a word document or text in Word format to standard text.
    So that we can use that standard text in Script output.
    This might be very useful if we need to convert a lot of text into standard text.

    Hi,
    Create the name of the standard text you want in SO10.
    When the editor is called up, select Text -> Upload and then browse for your file(s). Must be saved in RTF format in Word remember.
    Cheers
    Colin.

  • Can't print text documents

    For a little over a week I have been unable to print text documents from either of my printers (Lexmark Z-23 and HP PSC 1410). I had noticed that the sharpness of text had been declining-but I was in denial, sort of. Now, when printing text documents from the computer, the printout is garbled, streaked, and unreadable. Sometimes the first half of printed document will be okay but the second half will be all garbled and streaked.
    I have tried to print from Pages, Appleworks, and TextEdit. No success in any of them. I have converted a page of my word processing document to pdf format, but it does not print out properly in pdf, either.
    Here's the weird part: the HP will produce good copies (copy function) I am able to print out beautiful iCal (calendar) pages; some web-based information (like maps with directions) comes out great; and even "screen-shots" (or pictures) of text documents are fine; I just can't print text-based documents.
    So far, I have cleaned and calibrated the printers; they have enough ink. I have uninstalled then reinstalled the software and drivers.
    Help?
    ~~PM
    iMac G5 2GHz PPC   Mac OS X (10.4.8)   still miss my Indigo G3

    my guess is, it's not your printers that are the
    problem but maybe a font problem.
    Have you done anything with fonts lately?
    Why, yes.
    Just today, in FontBook I validated fonts and
    resolved duplicates, whatever that means. I also
    "turned off" a bunch of fonts that I never use. Then
    I restarted, reset PRAM, and repaired permissions in
    Disk Utility.
    I still have the problem.
    What other kinds of things can you do with fonts?
    ~PM, wife of GM
    Glenn-- Here is a great article written by a fellow apple forum frequenter:
    http://www.jklstudios.com/misc/osxfonts.html
    Maybe you can read it or weed thru it and make sure you haven't turned off any necessary fonts that you don't use but the system finds necessary. Especially "TextEdit" uses I think exclusively system fonts and if you've turned them off... It's just good to know which fonts are for what before you disable certain ones.
    I believe fonts can definitely cause these sorts of problems, especially if you've disabled system fonts.

  • Just converted a PDF document to Word, none of the graphics from the PDF file show up in the Word document?

    Just converted a PDF document to Word, none of the graphics from the PDF file show up in the Word document?
    What do I need to do to bring the graphics and exhibits from the PDF file to the Word file?

    Hi jackp52432917,
    How was that PDF file created? Please see  Will Adobe ExportPDF convert both text and form... | Adobe Community
    It could be that the PDF file you're converting was created using a third-party application, and it doesn't contain all the information necessary to ensure a clean conversion. Have you had similar troubles converting other PDF files?
    Best,
    Sara

  • Sending a text document as pdf by email.

    Hi,
    I have a plain text document that needs to be send as a pdf document by email. The line type of the text document is PC408-linda, which is 132-character length. I am trying to use the FM ‘SO_NEW_DOCUMENT_ATT_SEND_API1’ for sending the document which uses structure ‘SOLISTI1’ for sending the document. The line size of SOLISTI1 is 256 characters. I tried to send 132-character length internal table instead of the given structure for the FM, it didn’t work. Later, I put the 132-charcter line into the 256-character length line, which works well. But, I have a problem when the outgoing system converts the 256-character length into pdf document. It breaks the line.
    Can you please suggest me how can I fit this 132-chracter line in the above FM or Is there any alaternateive FM for sending this 132-character lines, which will fit in the pdf format.
    Lokman

    Hi,
    Here I am sending the part of the code that is sending the text document by using FM. Internal table $form conatins 132-character length text document. I want to send this document so that converted pdf appears similar to text line.
    FORM send_email USING $form TYPE tt_form.
    DATA:
        $form_wa1  LIKE pc408.
    data: paydate(15) type c.
    Data  date like sy-datum.
    *date = sy-datum.
    Email Subject.
    DATA: s1(30)  TYPE c VALUE  ' Avis - Bulletin de paie du ',
            s3(50)  TYPE c .
    loop at $form into $form_wa1.
    if sy-tabix eq 10.
    MOVE $form_wa1-linda+5(10) TO paydate.
    endif.
    objtxt-line = $form_wa1-linda.
    append objtxt.
    endloop.
    CONCATENATE s1 paydate INTO s3 separated by SPACE.
    *Email message body.
    DATA: c1(30)  TYPE c VALUE  'Vous trouverez ci-joint',
          c2(50) type c value ' votre bulletin de paie du  ' ,
          c type c value '.',
          c4(85)  TYPE c.
    CONCATENATE c1 c2 paydate c INTO c4 separated by SPACE.
    data: a1(40) type c value 'À ouvrir avec le programme "Notepad" ',
       a2(47) type c value ' ou "Wordpad" pour le visualiser correctement.',
       a3(90) type c.
      CONCATENATE a1 a2 INTO a3.
    data: b1(45) type c value ' Pour imprimer, veuillez vous ',
        b2(45) type c value ' assurer que les marges (droite et gauche)',
        b3(35) type c value ' sont restreintes au minimum.',
       b4(200) type c.
       CONCATENATE a3 b1 b2 b3 INTO b4.
    Main Text
    data wa_form like PC408 .
    Email Subject
    docdata-obj_name = 'TEST_ALI'.
    docdata-obj_descr = s3.
    Email Message
    objtxt = 'Bonjour,'.
    append objtxt.
    objtxt = ' '.
    append objtxt.
    objtxt = c4.
    append objtxt.
    objtxt = ' '.
    append objtxt.
    objtxt = b4.
    append objtxt.
    describe table objtxt lines tab_lines.
    read table objtxt index tab_lines.
    docdata-doc_size = ( tab_lines - 1 ) * 255 + strlen( objtxt ).
    clear objpack-transf_bin.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = 'RAW'.
    append objpack.
    Create Message Attachment
    Write Packing List (Attachment)
    loop at $form into $form_wa1.
    *if sy-tabix eq 10.
    *MOVE $form_wa1-linda+5(10) TO paydate.
    endif.
      objtxt-line = $form_wa1-linda.
      append objtxt.
    endloop.
    att_type = 'RAW '.
    describe table objtxt lines tab_lines.
    read table objtxt index tab_lines.
    objpack-doc_size = ( tab_lines - 1 ) * 255 + strlen( objtxt ).
    clear objpack-transf_bin.
    objpack-head_start = 6.
    objpack-head_num = 0.
    objpack-body_start = 6.
    objpack-body_num = tab_lines.
    objpack-doc_type = att_type.
    objpack-obj_name = 'ATTACHMENT'.
    objpack-obj_descr = 'Attached Document'.
    append objpack.
    Create receiver list
    reclist-receiver = wa_pa0105-usrid. "<-- change address
    *reclist-receiver = '[email protected]'. "<-- change address
    reclist-rec_type = 'U'.
    append reclist.
    *reclist-receiver = sy-uname. "<-- change internal user
    *reclist-rec_type = 'B'.
    *append reclist.
    Send Message
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = docdata
    PUT_IN_OUTBOX = 'X'
    IMPORTING
    SENT_TO_ALL =
    NEW_OBJECT_ID =
    tables
    packing_list = objpack
    OBJECT_HEADER = objhead
    *CONTENTS_BIN = objbin
    CONTENTS_TXT = objtxt
    OBJECT_PARA =
    OBJECT_PARB =
    receivers = reclist
    EXCEPTIONS
    TOO_MANY_RECEIVERS = 1
    DOCUMENT_NOT_SENT = 2
    DOCUMENT_TYPE_NOT_EXIST = 3
    OPERATION_NO_AUTHORIZATION = 4
    PARAMETER_ERROR = 5
    X_ERROR = 6
    ENQUEUE_ERROR = 7
    OTHERS = 8
    refresh: objtxt,
             objpack,
             objhead,
             reclist.
    IF sy-subrc <> 0.
    message ID 'SO' TYPE 'S' NUMBER '023'
    with docdata-obj_name.
    ENDIF.
    *write: / 'End of Program'.
    ENDFORM.                    " send_email

  • Acrobat X 10.02 crashes when converting Word 2007 document wiht linked Visio file.

    Acrobat X 10.02 crashes when converting Word 2007 document with linked Visio file and causes a C++ runtime error in Word and crashes Word.
    To see the behavior create a short Word 2007 document with a linked Visio file (e.g., create a Visio file with one box and text and insert it as a link into a Word docx).
    No problem in Acrobat 9

    There may be some of an issue with AA X on this, but part of the blame probably goes to MS also. I would suggest you simply clip the graphic from VISIO as a vector graphic (EMF will be used by default) and not do the link and do not embed the VISIO object. The linking and use of embedded objects in WORD 2007 seems to have been a major problem and is mostly a MS issue.

  • How do I copy a few lines from a pdf document to a Word document?  I'm not looking to convert the whole document, just need to copy a few lines here and there.

    How do I copy a few lines from a pdf document to a Word document?
    I'm not looking to convert the whole document, just need to copy a few lines here and there.
    ps.  Wow, what a user UNFRIENDLY site this is!

    In most cases you can just select the text and copy/paste. You can do that unless the file is a picture/scan.

  • Reading a pdf document in C# or Converting a pdf document to XML

    Hi All,
    My basic requirement is to convert any pdf document conatining text to XML with help of C# .NET.
    Any help is most appreciable.
    Thanks in advance.
    Sudhir

    Unfortunately our ExportPDF service doesn't support Hebrew text.  You can vote for this feature in here: http://forums.adobe.com/ideas/1554  We use the Ideas section to help prioritize features.
    -David

  • PDF Scanned in a PDF Text document?

    How can I convert a PDF Scanned file in a PDF text document??
    Regards

    Unfortunately, you cannot change a scan into live text using Adobe Reader. At a minimum you would need Adobe Acrobat to run what's called Optical Character Recognition.
    What I've recommended to people in the past is to use the drawing markup tools to draw boxes around the text they want highlighted then play around with the fill color of the box until they get something close to what they want.

  • How do I convert mail merge documents to individual pdf docs and save each with a field in the merge?

    How do I convert mail merge documents to individual pdf docs and save each with a field in the merge?

    Is this an actual field, or just some piece of static text somewhere? Either way, you can't do it using the Split Document command. You'll need to use a custom-made script to read the value of this "field" and use it when extracting pages from the file.

  • How do I convert a scaned document to pdf?

    How do I convert a scanned document to pdf.

    Hi William,
    Here you go!
    How to export your PDF file to Word file:
    1.Log into https://exportpdf.acrobat.com/signin.html with your Adobe ID and password
    2. Select "Export from PDF' from right pane
    3. Click "Select Files" button then choose your PDF file for exporting to Word file
    4. Select a format like docx or doc for Word file
    5. Check On for "Recognize scanned text in" if your PDF file contains scanned images
    6. Click "Export" button
    7. Download the Word file by clicking "Download" in the progress bar
    8. Open the Word file in Microsoft Word for editing.
    Or you can export your PDF file in Adobe Reader
    1. Launch Adobe Reader and open your PDF file
    2. Select "Tools" and click "Sign In" link to sign in with your Adobe ID and password
    3. Select "Export PDF"
    4. Click "Convert" button
    5. Click "Download Converted File" link to download the exported Word file to your computer.
    Regards, Stacy

  • Save a numbers spreadsheet as a simple text document?

    How do you save a numbers spreadsheet as a simple text document? I can't seem to find this option anywhere. Simply renaming the extension also seems to maintain rich text.

    An extension name is just a reminder helping us and the operating system to recognize which kind is the contents of a given file.
    Changing a trousers against a dress will not change Mr. Obama in Mrs. Clinton;-)
    Same thing for the files.
    At this time, Numbers doesn't offer the ability to export as a text file.
    Happily, our machines are delivered with TextEdit.
    Copy the block of cells of your choice to the clipboard
    Paste in an empty TextEdit document
    Format > Convert as text
    Save
    That's all folks.
    Of course, you may
    _Go to "Provide Numbers Feedback" in the "Numbers" menu_, describe what you wish.
    Then, cross your fingers, and wait _at least_ for iWork'09
    Yvan KOENIG (from FRANCE mardi 5 août 2008 18:07:34)

Maybe you are looking for

  • Firefox often crashes when I watch a Flash video

    If my memory serves me right, it doesn't necessarily need a video to crash. I tried Safe Mode and memtest86+, Safe Mode crashed anyway and memtest found nothing wrong. Also, I tried updating Flash to the latest version, without any improvement. == Cr

  • G++ / JNI / dependencies

    Hi, I'm trying to build a jni library on SPARC Solaris 8 using g++. The library works just fine, however I appear to have to have libgcc installed on the machines where I want to use the library. I'm building the library with the following command li

  • Tried to restart apple tv. Now it is frozen on the apple

    My apple TV has been running poorly. Attempted to update software but it was unsuccessful. Attempted to restart and now it is frozen on the apple screen.  Help

  • T code F-28 Upload

    Hello, Folks, Could you please help me?  I just wanted make upload directely from some excel file to t-code f-28. How can I do it? Best Regards, Queiroz

  • Reg: Standby Database

    Hello, In StandBy database, Is it necessary to cancel the MANAGED RECOVERY MODE before performing the SHUTDOWN immediate option. IF yes WHY or instead of cancelling can i directly issue the SHUTDOWN IMMEDIATE; command Thanks, Sunil