This is about recursion and the print out

Please give me a "HINT" on how to;
1- Control the way I print the file out, like instead of printing "A, B, C, D, E, F", printthe alphabets in two lines of three alphabets, like;
"A, B, C"
"D, E, F"
2- A hint on writing a recursion method so I can print out from more than one inFile.
This is what I have so far.import Alphabets;
import java.util.StringTokenizer;
import java.io.*;
public class PrintAlphabets
   public static void main (String[] args) throws IOException
     int n= 100;
      Alphabets[] letters= new Alphabets[n];   //array of numbers
      StringTokenizer tokenizer;
      String line, name;
      String units;     //number of Alphabets available in the file.
          int count = 0;
      String fileout = "c:\\Alpha.txt";
     File file = new File(args[0]);
      FileWriter fw = new FileWriter (fileout);
      BufferedWriter bw = new BufferedWriter (fw);
      PrintWriter outFile = new PrintWriter (bw);
      try
           FileReader fr = new FileReader (file);
           BufferedReader inFile = new BufferedReader (fr);
           line = inFile.readLine();
           while (line != null)
               tokenizer = new StringTokenizer (line);
                 while (tokenizer.hasMoreTokens())
                   try
                      units = tokenizer.nextToken();
                       if ( units.equals("#include") )
                          tokenizer.nextToken();
                       else
                      letters[count++] = new Alphabets (units);
                   catch (Exception e)
                      System.out.println ("Error in input. Line ignored:");
                      System.out.println (line);
             line = inFile.readLine();
         inFile.close();
          for (int scan = 0; scan < count; scan++)
                        outFile.print (letters[scan] + " " );
      catch (FileNotFoundException exception)
         System.out.println ("The file " + file + " was not found.");
      catch (IOException exception)
        System.out.println (exception);
            System.exit(0);
           outFile.close();

I thought I send you te whole code again because I still get the "null" thing.
import Alphabets;
import java.util.StringTokenizer;
import java.io.*;
public class PrintAlphabets
   public static void main (String[] args) throws IOException
     int n= 100;
      Alphabets[] letters= new Alphabets[n]; ;  //array of numbers
      StringTokenizer tokenizer;
      String line, name;
      String units;    
          int count = 0, printCount=0, scan=0;
      String fileout = "c:\\AlphaResult.txt";
     File file = new File(args[0]);
      FileWriter fw = new FileWriter (fileout);
      BufferedWriter bw = new BufferedWriter (fw);
      PrintWriter outFile = new PrintWriter (bw);
      try
           FileReader fr = new FileReader (file);
           BufferedReader inFile = new BufferedReader (fr);
           line = inFile.readLine();
           while (line != null)
               tokenizer = new StringTokenizer (line);
                 while (tokenizer.hasMoreTokens())
                   try
                      units = tokenizer.nextToken();
                       if ( units.equals("#include") )
                          tokenizer.nextToken();
                       else
                      letters[count++] = new Alphabets (units);
                   catch (Exception e)
                      System.out.println ("Error in input. Line ignored:");
                      System.out.println (line);
             line = inFile.readLine();
         inFile.close();
          for (scan = 0; scan < count; scan++)
                        if (printCount == 3)
                           {   outFile.println(); 
                                printCount = 0;
                         String newLine = System.getProperty("line.separator");
                         outFile.print(newLine + letters[scan] + " " );
                        printCount++;
                        //System.out.println(letters[scan] + " "  );
                        //outFile.print (letters[scan] + " " );
      catch (FileNotFoundException exception)
         System.out.println ("The file " + file + " was not found.");
      catch (IOException exception)
        System.out.println (exception);
            System.exit(0);
           outFile.close();
}

Similar Messages

  • I am trying to print a  jpg, centered on the page, to epson printer and the printed image is off center, does anyone have a sense about setting to check?

    i am trying to print a  jpg, centered on the page, to epson printer and the printed image is off center, does anyone have a sense about setting to check?

    right click a blank area of the toolbar, click Customize. You'll see the printer icon there. Drag and drop it to where you want.
    You can also find this option under View -> Toolbars -> Customize.

  • My mac has stopped connecting to the wireless printer. However both the mac and the printer indicate that they are connected. What can I do to correct this issue?

    my mac has stopped connecting to the wireless printer. However both the mac and the printer indicate that they are connected. What can I do to correct this issue?

    Maybe this???
    Mac OS X: About the Reset Printing System feature ...
    http://support.apple.com/kb/HT1341?viewlocale=en_US
    10.5/10.6/10.7/10.8 instructions...
    In System Preferences>Fax & Print, Right click or Control+click on the Printers list Sidebar, choose Reset Printing System.
    if you hold option and click the "-" tab it resets the printing system.
    http://www.macosxhints.com/article.php?story=20031215144430486
    Safe Boot from the HD, (holding Shift key down at bootup), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions.
    Any devices that previously appeared in your Printer List and Fax List will need to be added again after resetting the printing system.
    Resetting the printing system in Mac OS X 10.5.x+++
        1.    To use the Reset Printing System feature in Mac OS X 10.5.x, follow these steps:
        2.    Choose System Preferences from the Apple menu.
        3.    Choose Print & Fax from the View menu.
        4.    Control-click on list of printers on the left side of the window, then choose "Reset printing system" from the contextual menu. If you don't see a list of printers, Control-click on the text "Click + to add a printer or fax" and select "Reset printing system..." 
   
  As an alternative, if you currently have one or more printers listed, you can Option-click the "-" (Remove printer) button.
    http://support.apple.com/kb/ht1341
    Reboot.

  • HP4620 will not print black BUT i can scan a copy to the printer and then print out black

    AS soon as i changed the black print cartridge it stopped printing black copies    but i can scan a document to the pc and then print it and it prints out perfect .... this is the third HP printer that i have (different models) where the SAME thing happens... i just sent 105.00 for cartridges that the printer still does not print.  I'm not understanding why i can print out a scanned document but cannot print anything else   PLEASE help me because ive already wasted 105.00 .... i've done everything ... cleaned the printheads 20 times and also reset printer to factory defaultsNOTHING WORKS .......

    Hi,
    I am currently replying to this as it shows in the iChat Community.
    I have asked the Hosts to move it to Snow Leopard  (you should not lose contact with it through any email links you get)
    I also don't do Wirelss printing so I can't actaully help either.
    10:01 PM      Friday; July 29, 2011
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb( 10.6.8)
     Mac OS X (10.6.8),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • How do I put a online form on the web to be filled in and then printed out

    I created a pdf form with fields to be completed on our website.  Once the form is completed how do I get the person to print the completed form out as it looks on the website.  Also is there an option to email the completed form as it appears on the website?

    Josh,
    I started it in Forms Central and them kept updating and finalizing the form in Acrobat Pro. What I want is to put the form on our website so can be completed and either printed out by that person or sent to us just as the form appears on the website all filled in. Is that possible?
    Thanks,
    Keith

  • HT1338 I'm trying to print a document fro safari and the print command is at the bottom of the page and not visible.  I can't move it up and the print command shortcut doesn't work.  How do I print this document.

    I'm trying to print a document from safari and the print command is at the bottom of the page and I can't move it up.  The print command shortcut doesn't work and I would like to know how I can print this document.

    Why do we have to install 2 add ins for something that should be built in? Please add this to the next version or an update to this one even. We should see the full path of a bookmark when we search for it. Show Parent Folder alone isn't enough if you have sub folders, so I installed Go Parent Folder as well in case of sub folders.

  • I find I am unable to print any photo because the program "Can't find a theme and the Print command wont work without at least one theme. How can I overcome this problem?

    I find I am unable to print any photo because the program "Can't find a theme and the Print command wont work without at least one theme. How can I overcome this problem?

    reinstall iPhoto
    see this discussion down a few from your post
    https://discussions.apple.com/thread/5426566?tstart=0
    LN

  • When I bought my Mac they gave me a free hp printer. My mac is a 10.7 and the printer is for 10.6 and below.... so why did they give me this printer? Can I use it somehow or should I ask for a different one that is compatible with my computer?

    When I bought my Mac they gave me a free hp printer. My mac is a 10.7 and the printer is for 10.6 and below.... so why did they give me this printer? Can I use it somehow or should I ask for a different one that is compatible with my computer?

    Can I use it somehow or should I ask for a different one that is compatible with my computer?
    No, that's not necessary.
    You Mac most likely sat in inventory before it was sold so the latest drivers were not installed.
    If you tried using the printer and couldn'tget it to work, go here >  http://www8.hp.com/us/en/support-drivers.html
    If this is a USB connected printer, make sure it's connected to your Mac, then at that link click:  Detect Your Product
    Download and install drivers for v10.7 / Lion.

  • What's this I hear about Gmail and the iPhone?

    I have a gmail account with my iphone. I opened up a thread a few days ago saying something about gmail and the iphone (I didn't get to read the thread though) making it sound like the emails would get to my phone faster or something.
    Anyone know what I'm talking about?

    what you are talking about is called "pull", the phone pulls new messages every 15 minutes.
    in "push" mode if someone sends you an email it is pushed to your phone instantly, you don't have to wait up to 15 minutes for it to show up.
    you can find information about "push" vs. "pull" email on the internet (google works well for searching for information), wikipedia is especially handy:
    http://en.wikipedia.org/wiki/Push_e-mail
    and here is info about gmail push:
    http://googlemobile.blogspot.com/2009/09/google-sync-now-with-push-gmail-support .html

  • Value not populating in the print out (sales order) for the 1st time

    Hi friends,
    While saving a sales order, the order confirmation going to the user is not populating the LDC field. LDC is Last date of change. This field can be found in the Additonal data 2 tab of the material in the sales order. When I enter a date in this field and save, the print preview of the output has this value, but the print out does not carry this value.
    Another weird thing about this issue is that, the second time i trigger the output, the print out has the value.
    Please give me some clue on where to check and how to go about fixing this problem.
    Regards,
    Shanu.

    Dear Shanu,
    This issue may be related bug in the output program so take help of ABAPer to fix the issue.
    I hope this will help you,
    Regards,
    Murali.

  • Connect two external monitors to mini DP(using a mini DP to VGA adapter) and the VGA out at once

    I am trying to  connect two external monitors to mini DP(using a mini DP to VGA adapter) and the VGA out at once. Windows recognize both monitors as well. But it dowsn't let me use all three monitors at once(see the below image). In the dropdown, it lists all three monitors. Problem is there are two active displays I can select.

    Mavec wrote:
    I would like to add a third monitor.  
    The GPU(s) in your T400 (and most other laptop brands) will support two different displays concurrently.  If you want to support more than two different displays concurrently, you will need another GPU external to the T400.
    Generally, if you want to use two external displays on a T400 you will nee dto use a docking station.
    I have read messages on various fora on this topic and know that there are a number of ways of doing this, but as I have never had a need to do this myself I can't tell you how to go about it.
    Cheers,
    Bill
    I don't work for Lenovo

  • The word "ORIGINAL" is not appearing in the print out of documents

    Hi,
    For some reason the word "ORIGINAL" does not appear in the print outs (A/R Invoice, etc) anymore. But the word "COPY" appears when we reprint the documents. We could not see any setting in SAP that relates to this, and no changes in the PLD has been made prior to this issue. What could we be missing?
    Thank you,
    eric

    Hi Eric,
    The "Copy" remarks will be printed if you print a printed documents. Sometimes documents automatically change into "Open-Printed" event if we not actually print it.
    The solution is to chnge that remarks in the PLD to text "Original".
    Cheers

  • How can i take out the print out of invoices

    i want to see the print preview of billing document and i want to take the  print out also
    but i m unable to do this
    so wat is the navigation to do this please suggest.
    regards
    subrat

    Output of Invoice:
    Billing document (Change Mode) : VF02 --> Enter (takes to main screen) --> on the top line Goto --> Header --> Output  --> maintain output type --> Enter --> back --> Enter printer (in most cases LOCL) --> Enter & SAVE.
    Move out of billing document & revisit Billing Document in change mode(VF02) --> In the initial screen itself, on the top line o to Billing Document --> Output --> Screen / preview > Enter> a screen will pop-up on which printer name is mentioned --> Enter & you will get the preview of Invoice.
    To Configure printer, take assistance from basis consultant.
    Regards,
    Rajesh Banka

  • How to take the print out of the entire data from the waveform chart

    i am using cont acq to spreadsheet file.vi to acquire data from a number of channels. this vi also plots the acquired data on the waveform chart. i want to take the print out of the entire data. how can i do it ?
    also how can i take print out of the data between given interval??
    please reply me
    thank you

    There are a number of different ways of achieving your goal. Depending on which version of LabVIEW you have and which development environment, the Report Generation Toolkit is a very powerful tool. Attached is an example that prints the acquired data without the use of additional toolkits.
    Jonathan Hildyard
    Applications Engineer
    National Instruments
    Attachments:
    DAQ_with_Print.llb ‏115 KB

  • I have a e printer and thee printer is on the same wifi net work as the iPad, when I select print from the iPad the response is no printers. I can successfully email from my iPad to the printer. How can I make my iPad recognize the printer?

    I have an e printer and the printer is on the same network as the iPad. When I attempt to print from the iPad I get a message no printers available. How can I get my iPad to recognize the e printer?

    This printer has worked for me with out fail at my house.  I am traveling in an RV and am at the mercy of the RV Wifi.  I do not have access to the router.  The printer has been recycled a number of times as well as the Ipad.  The printer is set up and has access to the wifi.  It seems to me that the Ipad and Iphone are not recognizing the connection with the e printer.  I was hoping there was some adjustment that could be made to the Ipad and Iphone.  I can email to the printer from both gadgets.  I will try to recycle the devices again.

Maybe you are looking for