How to print a character return in a txt file?

i tried this line of code
" outFile.print(lines.get(k) + "\n"); "
where "lines" is an arraylist that stores only strings
everything works fine, except the "\n" doesn't really give me a character return, ie. i want the file to start on a new line after printing lines.get(k). but it doesn't.
what should i put in the place of \n?
thanks a lot!

yea, i load the saved file into notepad, and all i see is something like || (2 little bars) instead of a return, and the next word continues on the same line instead of going to the next line
...... _-- ||||||                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • How to Print a Character in Reverse video ...?

    Hi Could any one of you help me " How to print a character in Reverse Video " in SMART Forms and in SAP Scripts.
    Regards,
    Saravanan
    <MOVED BY MODERATOR TO THE CORRECT FORUM>
    Edited by: Alvaro Tejada Galindo on Mar 26, 2009 5:31 PM

    deepak_c3 wrote:
    Thanks for the info.,
    where should the page number n-1-i be returned ?
    Which method implementation of Pageable interface should return the page number ?w.r.t. your first question: don't return that number but return page n-1-i when page i is requested; your document will be printed in reverse order. Your class should implement the entire interface and wrap the original Pageable. (for that number n your class can consult the wrapped interface; read the API for the Pageable interface).
    kind regards,
    Jos

  • Writing the ASCII value of a character found in a .txt file

    I have a program that reads in a file and outputs certain characters to a new smaller file. The program works fine (thanks to some forum help) but I now need to print the ASCII value of the characters that are written to the file.
    The problem I'm having (besides writing the ascii value of the char) is that the Unix .txt file has some weird properties. When I run the program on a .txt test file that I created with spaces in it, the program ignores the space characters.
    Yet, when I run the program on the Unix file it wites the 'spaces' to the output file. That is why I want to write/print the ASCII value of the "blank "character in the Unix .txt file.
    I already serached the forum and did a Google search for Char to ASCII conversion but I didn't find anything.
    Thanks,
    LS6v
    Here's the code and the clips of the ouput files:
    package source;
    import javax.swing.*;
    import java.io.*;
    public class Scanner4
         public static void main(String[] args)
              getContents();
              System.exit(0);
         public static void getContents()
              char charArray[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
                                         'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
                                           '0','1','2','3','4','5','6','7','8','9','$','.', '#', '-', '/', '*', '&', '(', ')',' '};
              String Chars = null;
              String lineSep = System.getProperty("line.separator");
              int iterator = 0;
              int i = 0;
              int charNum = 1;
              int lineCount = 1;          
             // StringBuffer contents = new StringBuffer();
             //declared here only to make visible to finally clause
             BufferedReader input = null;
             BufferedWriter out = null;
             try {
                         //use buffering
                         //this implementation reads one line at a time
                         input = new BufferedReader( new FileReader( "C:\\testFile\\test1.txt" ));
                         out = new BufferedWriter( new FileWriter( "C:\\Scan file test\\Write\\test.txt" ));
                         String line = null;
                    out.write( "Character\tLine Number\tCharacter Number" + lineSep ); 
                              while (( line = input.readLine()) != null)
                               //contents.append(System.getProperty("line.separator"));
                               i = 0;
                               charNum = 1;
                               iterator = 0;
                              while( i < line.length() )
                                             for( int count = 0; count < charArray.length; count++)
                                                  if( (charArray[count] != line.charAt(iterator)) && (count+1 == charArray.length) )
                                                       out.write( "[" + line.charAt(iterator) + "]\t\t" + "[" + lineCount + "]\t\t" + "[" + charNum + "]" + lineSep);
                                                  if( charArray[count] == line.charAt(iterator) )
                                                       break;
                                        charNum +=1;
                                        iterator +=1;
                                        i++;                               
                                 lineCount +=1;
             catch (FileNotFoundException ex) {ex.printStackTrace();     System.out.println("File not found.");}          
                 catch (IOException ex){ex.printStackTrace();               System.out.println("IO Error.");}
             finally
                           try{
                                 if (input!= null){
                               //flush and close both "input" and its underlying FileReader
                                 input.close();
                                 out.close();
               catch (IOException ex){ex.printStackTrace();  System.out.println("IO Error #2.");}
    My created .txt file:
    1. a!asdsad
    2. @
    3. #
    4. $
    5. %sdfsdf
    6. ^
    7. &
    8. *
    9. (
    10. )
    11. _
    12. +sdfsdfsdf
    13. -
    14. =
    15. ~
    16. `
    17. dfgdfg;
    18. :
    19. '
    20. "fghfghf
    21. ,
    22. dfgdfg<
    23. .
    24. >fghfghfg
    25. /
    26. gggggggggggggggggggggggg?
    27. a
    Output for my .txt file:
    Character     Line Number     Character Number
    [!]          [1]          [5]
    [@]          [2]          [4]
    [%]          [5]          [4]
    [^]          [6]          [4]
    [_]          [11]          [5]
    [+]          [12]          [5]
    [=]          [14]          [5]
    [~]          [15]          [5]
    [`]          [16]          [5]
    [;]          [17]          [11]
    [:]          [18]          [5]
    [']          [19]          [5]
    ["]          [20]          [5]
    [,]          [21]          [5]
    [<]          [22]          [11]
    [>]          [24]          [5]
    [?]          [26]          [29]************************************************************************
    Output generated after reading the .txt file from the unix box:
    Character     Line Number     Character Number
    [ ]          [1]          [17]
    [ ]          [1]          [18]
    [ ]          [1]          [19]
    [ ]          [1]          [6530]
    [ ]          [2]          [2041]
    [']          [29]          [1834]
    [']          [29]          [2023]
    [']          [30]          [1834]
    [']          [30]          [2023]
    [']          [30]          [2066]
    [']          [47]          [2066]
    [']          [67]          [2067]
    [']          [77]          [2066]
    [+]          [80]          [28]

    Thanks I didn't even think to try and cast it to an int...
    The tool I'm using to create my .txt in windows is Notepad.
    I wrote a program to simply copy the original (3GB) Unix file and terminated it early so I could see what was there. What I found was some text and symbols and a lot of space between brief bursts of text. I can't really copy and paste an example because the amount of space is too large, it's basically a 3GB unformatted .txt file...
    Unix file was created on: unknown
    It sounds like the .txt file that I copied from the Unix box was formatted differently. But I thought that the formatting had more to do with end of line issues, not blank space between characters. Because a blank space should be seen by my program and ignored...
    Here's the ASCII value of the "blank" spaces:
    Character     Line Number     Character Number
    [ ]          [1]          [17]     Ascii Value: [0]
    [ ]          [1]          [18]     Ascii Value: [0]
    [']          [868]          [2066]     Ascii Value: [39]
    [,]          [877]          [186]     Ascii Value: [44]
    [,]          [877]          [276]     Ascii Value: [44]
    Also, the Ascii value printed for the blank spaces looks like the number zero here but it looks like it has strange points on the bottom of it in my output file. It looks like the extended ASCII character 234 &#937;

  • How to write a code for  open new txt file in swing

    hai all,
    now i do one project in java.that project's GUI is Swing. But i don't known swing (basic).So how to write a code for open new txt file and "Open window " in menu item on swing.that means when i click the "New" on menu that time open a new txt file. open also like that type.
    plz give me that code ! very urgent
    Advance Thanks !
    RSK

    Swing Tutorial:
    http://java.sun.com/docs/books/tutorial/uiswing/index.html
    Since you don't know the basic of swing read the tutorial, it is for your own good because it is useless if we provide you with a code you don't even understand and how it works.
    If you want a menu read the tutorial about using menus and for opening a file read using JFileChooser.
    note: don't use the word urgent because it implies that your problem is more important than others.

  • HT2486 How to print the same return label on Avery labels

    I am trying to print the same return label on an Avery 5160 and cannot. It only shows one label, not 30 of the same.
    Was on the phone with Apple support but we could not make it work either.
    Anyone knows?
    Thanks

    REDP,
    I am sorry, but to get your issue more exposure I would suggest posting it in the commercial forums since this is a commercial printer. You can do this at http://h30499.www3.hp.com/hpeb/ .
    I hope this helps.
    ↙-----------How do I give Kudos?| How do I mark a post as Solved? ----------------↓

  • How to print Chinese character in Zebra printer?

    Hi,
    Could you please advise how to print Chinese in Zebra printer, I have added below ZPL command line in SAPSCRIPT, but it did not work.
    ^CW1,B:MSUNG.FNT
    FO711,60A1N,47,79CI17F8FB1561,3,0,LFN998^FS

    Hi,
    go through the following links.
    [Printing Chinese Characters on Labels using ZEBRA;
    I hope it helps.
    Regards,
    Rohit

  • How to print the mirror image of a pdf file?

    Hi,
    Does anyone know if it is possible to print the mirror image of a pdf file? I could have sworn I have done this before in an older version of Acrobat.
    I am currently working with Adobe Acrobat 8.0 Professional.
    Thank you,
    Tina

    I just tested this and it worked fine for me.
    When you select to print the cropped page, in the print dialog will be a thumbnail of what is about to be printed. Does this display just the cropped portion or the whole page?

  • How to print specific pages out of a book file

    I've searched around but I cannot find any way of printing specific pages out of a book file. Has anyone got any ideas? I have a 100 page book file with 20 files, and doing print outs of sections is a nightmare. I want to be able to print page 5 out of file A and page 6 out of file B together so I can duplex them. I've tried scripting this but I can't seem to set the page range of the print preferences of the book file.

    [Jongware] wrote:
    I don't think it's possible to set the page range of a Book.printPreferences
    Theoretically it ought to be possible. Can't test for myself now; what does happen when you set the pageRange to overlapping sub-files?
    I've just tried it with CS3. It might have been implemented in later versions.
    In the print Book dialogue the page range field is disabled. You cannot enter anything there.
    If you try to do it with a script it says that printPreferences is read only.

  • How to read the last line in a txt file?

    Dear all,
    I want to read the last line in a txt file. There are thousands of lines in this file. What I want is to move the file pointer directly to the last line of the file. But I did not know how do to it. Can anybody help me out?
    Thank you very much!

    If the file is coded as ASCII or one of the encodings that maps a single byte to a char then the following class will assist you
    import java.io.*;
    import java.util.*;
    public class GetLinesFromEndOfFile
        static public class BackwardsFileInputStream extends InputStream
            public BackwardsFileInputStream(File file) throws IOException
                assert (file != null) && file.exists() && file.isFile() && file.canRead();
                raf = new RandomAccessFile(file, "r");
                currentPositionInFile = raf.length();
                currentPositionInBuffer = 0;
            public int read() throws IOException
                if (currentPositionInFile <= 0)
                    return -1;
                if (--currentPositionInBuffer < 0)
                    currentPositionInBuffer = buffer.length;
                    long startOfBlock = currentPositionInFile - buffer.length;
                    if (startOfBlock < 0)
                        currentPositionInBuffer = buffer.length + (int)startOfBlock;
                        startOfBlock = 0;
                    raf.seek(startOfBlock);
                    raf.readFully(buffer, 0, currentPositionInBuffer);
                    return read();
                currentPositionInFile--;
                return buffer[currentPositionInBuffer];
            public void close() throws IOException
                raf.close();
            private final byte[] buffer = new byte[4096];
            private final RandomAccessFile raf;
            private long currentPositionInFile;
            private int currentPositionInBuffer;
        public static List<String> head(File file, int numberOfLinesToRead) throws IOException
            return head(file, "ISO-8859-1" , numberOfLinesToRead);
        public static List<String> head(File file, String encoding, int numberOfLinesToRead) throws IOException
            assert (file != null) && file.exists() && file.isFile() && file.canRead();
            assert numberOfLinesToRead > 0;
            assert encoding != null;
            LinkedList<String> lines = new LinkedList<String>();
            BufferedReader reader= new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding));
            for (String line = null; (numberOfLinesToRead-- > 0) && (line = reader.readLine()) != null;)
                lines.addLast(line);
            reader.close();
            return lines;
        public static List<String> tail(File file, int numberOfLinesToRead) throws IOException
            return tail(file, "ISO-8859-1" , numberOfLinesToRead);
        public static List<String> tail(File file, String encoding, int numberOfLinesToRead) throws IOException
            assert (file != null) && file.exists() && file.isFile() && file.canRead();
            assert numberOfLinesToRead > 0;
            assert (encoding != null) && encoding.matches("(?i)(iso-8859|ascii|us-ascii).*");
            LinkedList<String> lines = new LinkedList<String>();
            BufferedReader reader= new BufferedReader(new InputStreamReader(new BackwardsFileInputStream(file), encoding));
            for (String line = null; (numberOfLinesToRead-- > 0) && (line = reader.readLine()) != null;)
                // Reverse the order of the characters in the string
                char[] chars = line.toCharArray();
                for (int j = 0, k = chars.length - 1; j < k ; j++, k--)
                    char temp = chars[j];
                    chars[j] = chars[k];
                    chars[k]= temp;
                lines.addFirst(new String(chars));
            reader.close();
            return lines;
        public static void main(String[] args)
            try
                File file = new File("/usr/share/dict/words");
                int n = 10;
                    System.out.println("Head of " + file);
                    int index = 0;
                    for (String line : head(file, n))
                        System.out.println(++index + "\t[" + line + "]");
                    System.out.println("Tail of " + file);
                    int index = 0;
                    for (String line : tail(file, "us-ascii", n))
                        System.out.println(++index + "\t[" + line + "]");
            catch (Exception e)
                e.printStackTrace();
    }Note, the EOL characters are treated as line separators so you will probably need to read the last two lines (think about it for a bit).

  • How to skip first 5 lines from a txt file when using sql*loader

    Hi,
    I have a txt file that contains header info tat i dont need. how can i skip those line when importing the file to my database?
    Cheers

    Danny Fasen wrote:
    I think most of us would process this report using pl/sql:
    - read the file until you've read the column headers
    - read the account info and insert the data in the table until you have read the last account info line
    - read the file until you've read a new set of column headers (page 2)
    - read the account info and insert the data in the table until you have read the last account info line (page 2)
    - etc. until you reach the total block idenfitied by Count On-line ...
    - read the totals and compare them with the data inserted in the tableOr maybe like this...
    First create an external table to read the report as whole lines...
    SQL> ed
    Wrote file afiedt.buf
      1  CREATE TABLE ext_report (
      2    line VARCHAR2(200)
      3          )
      4  ORGANIZATION EXTERNAL (
      5    TYPE oracle_loader
      6    DEFAULT DIRECTORY TEST_DIR
      7    ACCESS PARAMETERS (
      8      RECORDS DELIMITED BY NEWLINE
      9      BADFILE 'bad_report.bad'
    10      DISCARDFILE 'dis_report.dis'
    11      LOGFILE 'log_report.log'
    12      FIELDS TERMINATED BY X'0D' RTRIM
    13      MISSING FIELD VALUES ARE NULL
    14      REJECT ROWS WITH ALL NULL FIELDS
    15        (
    16         line
    17        )
    18      )
    19      LOCATION ('report.txt')
    20    )
    21  PARALLEL
    22* REJECT LIMIT UNLIMITED
    SQL> /
    Table created.
    SQL> select * from ext_report;
    LINE
    x report page1
    CDC:00220 / Sat Aug-08-2009 xxxxp for 02/08/09 - 08/08/09 Effective Date 11/08/09 Wed Sep-30-2009 08:25:43
    Bill to
    Retailer Retailer Name                  Name on Bank Account           Bank ABA   Bank Acct            On-line Amount  Instant Amount  Total Amount
    ======== ============================== ============================== ========== ==================== =============== =============== ===============
    0100103  BANK Terminal                  raji                           123456789  123456789            -29,999.98    9 0.00         99 -29,999.98
    0100105  Independent 1                  Savings                        123456789  100000002            -1,905.00     9 0.00         99 -1,905.00
    0100106  Independent 2                  system                         123456789  100000003            -800.00       9 -15.00       99 -815.00
    LARGE SPACE
    weekly_eft_repo 1.0 Page: 2
    CDC:00220 / Sat Aug-08-2009 Weekly EFT Sweep for 02/08/09 - 08/08/09 Effective Date 11/08/09 Wed Sep-30-2009 08:25:43
    Bill to
    Retailer Retailer Name Name on Bank Account Bank ABA Bank Acct On-line Amount Instant Amount Total Amount
    ======== ============================== ============================== ========== ==================== =============== =============== ===============
    Count On-line Amount Instant Amount Total Amount
    ============== ====================== ====================== ======================
    Debits 0 0.00 0.00 0.00
    Credits 3 -32,704.98 -15.00 -32,719.98
    Totals 3 -32,704.98 -15.00 -32,719.98
    Total Tape Records / Blocks / Hash : 3 1 37037034
    End of Report
    23 rows selected.Then we can check we can just pull out the lines of data we're interested in from that...
    SQL> ed
    Wrote file afiedt.buf
      1  create view vw_report as
      2* select line from ext_report where regexp_like(line, '^[0-9]')
    SQL> /
    View created.
    SQL> select * from vw_report;
    LINE
    0100103  BANK Terminal                  raji                           123456789  123456789            -29,999.98    9 0.00         99 -29,999.98
    0100105  Independent 1                  Savings                        123456789  100000002            -1,905.00     9 0.00         99 -1,905.00
    0100106  Independent 2                  system                         123456789  100000003            -800.00       9 -15.00       99 -815.00And then we adapt that view to extract the data from those lines as actual columns...
    SQL> col retailer format a10
    SQL> col retailer_name format a20
    SQL> col name_on_bank_account format a20
    SQL> col online_amount format 999,990.00
    SQL> col instant_amount format 999,990.00
    SQL> col total_amount format 999,990.00
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace view vw_report as
      2  select regexp_substr(line, '[^ ]+', 1, 1) as retailer
      3        ,trim(regexp_replace(regexp_substr(line, '[[:alpha:]][[:alnum:] ]*[[:alpha:]]', 1, 1), '(.*) +[^ ]+$', '\1')) as retailer_name
      4        ,trim(regexp_replace(regexp_substr(line, '[[:alpha:]][[:alnum:] ]*[[:alpha:]]', 1, 1), '.* ([^ ]+)$', '\1')) as name_on_bank_account
      5        ,to_number(regexp_substr(regexp_replace(line,'.*[[:alpha:]]([^[:alpha:]]+)','\1'), '[^ ]+', 1, 1)) as bank_aba
      6        ,to_number(regexp_substr(regexp_replace(line,'.*[[:alpha:]]([^[:alpha:]]+)','\1'), '[^ ]+', 1, 2)) as bank_account
      7        ,to_number(regexp_substr(regexp_replace(line,'.*[[:alpha:]]([^[:alpha:]]+)','\1'), '[^ ]+', 1, 3),'999,999.00') as online_amount
      8        ,to_number(regexp_substr(regexp_replace(line,'.*[[:alpha:]]([^[:alpha:]]+)','\1'), '[^ ]+', 1, 5),'999,999.00') as instant_amount
      9        ,to_number(regexp_substr(regexp_replace(line,'.*[[:alpha:]]([^[:alpha:]]+)','\1'), '[^ ]+', 1, 7),'999,999.00') as total_amount
    10* from (select line from ext_report where regexp_like(line, '^[0-9]'))
    SQL> /
    View created.
    SQL> select * from vw_report;
    RETAILER   RETAILER_NAME        NAME_ON_BANK_ACCOUNT   BANK_ABA BANK_ACCOUNT ONLINE_AMOUNT INSTANT_AMOUNT TOTAL_AMOUNT
    0100103    BANK Terminal        raji                  123456789    123456789    -29,999.98           0.00   -29,999.98
    0100105    Independent 1        Savings               123456789    100000002     -1,905.00           0.00    -1,905.00
    0100106    Independent 2        system                123456789    100000003       -800.00         -15.00      -815.00
    SQL>I couldn't quite figure out the "9" and the "99" data that was on those lines so I assume it should just be ignored. I also formatted the report data to fixed columns width in my external text file as I'd assume that's how the data would be generated, not that that would make much difference when extracting the values with regular expressions as I've done.
    So... something like that anyway. ;)

  • Editing and printing to the beginning of a txt file

    I have to questions that I have not been able to find much on. I have an output file but instead of the new data going on bottom I would like it to go on top. I'm sure there is a method or something but I have not been able to find it. Any help would be appreciated. And I would also like this txt file to be able to be edited throught the web page I'm using so in case something changes I don't have to go in and manual do the changes on the server. Thanks in advance for the help.

    alright I figured out how to put the values in at the top but I still would like a way to edit it in a browser. I was thinking of putting the entire text file back into a text area and when the submit button is hit it rewrites the entire file. Anyone done this before or got any better ideas. Thanxs.

  • How to print - when query returns nothing

    Hi All
    I have query...
    select sum((sum(nvl(ac.amtsourcedr,0))-sum(nvl(ac.amtsourcecr,0)))) as balance
    from fact_acct ac
    where ad_client_id=1000000
    and dateacct < '1/04/2010'
    and ac.account_id=1000432
    group by  ac.account_id
    I want to print zero when query returns nothing
    how to do that ..???
    thanking you in advance
    Regards
    gaurav

    use NVL
    select nvl(sum((sum(nvl(ac.amtsourcedr,0))-sum(nvl(ac.amtsourcecr,0)))),0) as balance
    from fact_acct ac
    where ad_client_id=1000000
    and dateacct < '
    and ac.account_id=1000432
    group by ac.account_idAnd yes you need to remove the Group By as stated by Toon, forgot to mention it
    Edited by: Karthick_Arp on May 27, 2010 4:04 AM

  • How to print a gift return label if only know the return number and order number

    I have a macbook pro, it's a gift, and I want to return it. But at first time, I forgot to print the return label, now I know the order number and return number, when I click "Print return label", it appeared I need to sign in, but I don't have a apple ID

    Call Apple sales and ask them. The number should be on your order receipt or look at the Contact Us link at the bottom right hand corner of this page.

  • How to print Chinese character in java

    Hi All,
    I have a problem .
    I am trying to read a file which contains chinese characters and the print the content of this file to the printer.
    But when the content of the file is being printed, it is printing weird characters and not chinese characters. Can anyone please help.
    Plese find below, my code.
    import java.io.*;
    import java.lang.*;
    import java.io.BufferedInputStream;
    class FileRead{
    //--------------------------------------------------< main >--------//
    public static void main (String[] args) {
    FileRead t = new FileRead();
    t.readMyFile();
    //--------------------------------------------< readMyFile >--------//
    void readMyFile() {
    String record = null;
    int recCount = 0;
    try {
         FileReader fr = new FileReader("amaebisushi.GB.TXT");
         FileOutputStream os = new FileOutputStream("\\\\ps_apex_1\\ps_lpt1");
    BufferedReader br = new BufferedReader(fr);
    PrintStream ps2 = new PrintStream(os);
    record = new String();
    while ((record = br.readLine()) != null) {
    recCount++;
    System.out.println(recCount + ": " + record);
    ps2.println(recCount + ": " + record);
    } catch (IOException e) {
    // catch possible io errors from readLine()
    System.out.println("Uh oh, got an IOException error!");
    e.printStackTrace();
    } // end of readMyFile()
    } // end of class

    Try not to rely upon the default encoding, but define it explicitly.

  • How to print double sided copy from a pdf file on a HP 8500a plus

    Have just purchased a new HP 8500a Plus Printer with a set up manual but no instruction booklet. Have recv'd a PDF file via email and would like to know,
    How do i print that PDF 4 page file from the computer to the printer - But double sided.
    Thank you if you can assist
    LeRoy

    HI,
    THIS might be of some help.
    Say "Thanks" by clicking the Kudos Star in the post that helped you.
    Although I work for HP my posts and replies are my own
    Please mark the post that solves your problem as "Accepted Solution"

Maybe you are looking for