I need help in multiple files!!!Please...

I already have a working class for this part.All I need is the application part that will create a property object for each data line read from the the input file assign4.dat. This application should also print each object to a data file, according to its category. If category 1, properties should be printed out to out1.dat, category2 to out2.dat, category 3 to out3.dat, and the rest to outRest.dat..Please help me start off my program.. I am a new programmer trying to learn new things..I would appreciate all your help..here is my working class, that works perfectly fine..and also the assign4.dat, for ur better understanding..Tnx..
import java.util.StringTokenizer;
import java.io.*;
public class Property{
     private int category;
     private double sellingPrice;
     private double commissionRate;
     private double commission;
     public void Property(String s){
          StringTokenizer tokenizer=new StringTokenizer(s);
          category=Integer.parseInt(tokenizer.nextToken());
          sellingPrice=Double.parseDouble(tokenizer.nextToken());
     public void Property(int cat, double selP){
          cat=category;
          selP=sellingPrice;
     public void setCommissionRate(){
          if(category==1)
          commissionRate=0.04;
          if(category==2)
          commissionRate=0.06;
          if(category==3)
          commissionRate=0.071;
     public void setCommissionRate(int i){
          if((i>=1)&&(i<=3))
               category=i;
               this.setCommissionRate(i);
          else
               commissionRate=i;
     public double getCommission(){
          commission=sellingPrice+commissionRate;
          return commission;
     public double getCategory(){
          return category;
     public String toString(){
          return "Price: "+sellingPrice+ " Category: "+category+ " Commission Rate: "+ commissionRate + " Commission: "+ commission;
}//end of property
//start of assign4.dat
1 457000
3 14550
2 49000
1 189000
2 24340
3 156700
3 78900
1 39000
1 345500
1 789000
2 550000
1 23500
4 78000
1 45000
5 899999

tnx again walken..but how do u extract the category part in the textfile..like the 1, 2, 3 for u to be able to print it out on a textfile those things..like read a line of text and then know whether it is 1, 2, 3..like i tried using the substring but then i had an error reading it...thats where i got stucked..here's the program..
import java.io.*;
import java.util.*;
public class TestProperty{
     public static void main(String args[]){
     //     String line;
     Property myProperty= new Property();
          try{
          FileReader inStream=new FileReader("assign4.dat");
          BufferedReader ins= new BufferedReader(inStream);
          FileWriter outStream=new FileWriter("out1.dat");
          PrintWriter outs = new PrintWriter(outStream);
          int lines=Integer.parseInt(ins.readLine());
          myProperty.getCategory();
          myProperty.getCommission();
          System.out.println(myProperty.toString());
     //     while(line!=null)
          for(int lineCount=0;lineCount<lines;lineCount++){
               String line=ins.readLine();
          //     line=ins.readLine();
               if(line.substring(0)=="1")
               outs.println(line);
               System.out.println(lines+"data lines written to file ");
          outs.close();
          ins.close();
          catch (IOException e){     
          System.out.println("i/o error:"+e.getMessage());
          e.printStackTrace();
          catch(NumberFormatException e){
               System.out.println(e.getMessage());
               e.printStackTrace();
}

Similar Messages

  • Possibly corrupt prefs.js file. Need help with this file please.

    I've been having a problem with sending/receiving text messages in Yahoo Messenger and I think I've narrowed it to the prefs.js file in Firefox. I'm using Firefox 3.6.25 on Windows XP sp3. The Yahoo Messenger window would not open when the appropriate mobile phone link was clicked. I uninstalled/reinstalled flash without change. I cleared cache, etc., without change. I created a new Firefox profile and I was able to get the Yahoo Messenger window to open. When I copied the prefs.js file from the old profile to the new profile, I encountered the problem again. I opened the prefs.js file with wordpad and noticed that editing should occur in about:config in the currently running Firefox browser. I briefly compared the two about:config tabs from the working profile and the non-working profile. They were significantly different. How do I make a copy of one so that I can paste it into wordpad and make the editing of the other one easier? Where can I find information about the individual parameters and their settings?

    Hi,
    Please see [[http://kb.mozillazine.org/About:config_entries this.]
    [http://kb.mozillazine.org/About:config about:config]
    You can try to '''Reset all user preferences to Firefox defaults:''' and '''Make Changes and Restart''' in the [https://support.mozilla.org/en-US/kb/Safe%20Mode Firefox Safe Mode] start screen which would also hopefully solve the issue. You can also try to manually '''Reset''' to defaults the modified entries by right-clicking on the bold entries (user set) in about:config. Clicking on the '''Status''' column header would sort the entries between user set (modified) and the defaults.
    An easy way would be to create a [https://support.mozilla.org/en-US/kb/Managing-profiles new profile] and [https://support.mozilla.org/en-US/kb/Recovering%20important%20data%20from%20an%20old%20profile?s=profile&r=1&e=sph&as=s copy/transfer the needed personal data] from the old profile and start using the new profile. You can then delete or troubleshoot the old proile. Firefox stores your personal data and settings in [http://kb.mozillazine.org/Profile_folder another location (profile folder)] separate from its [http://kb.mozillazine.org/Installation_directory folders/files]. A new profile would have the default Firefox settings in '''Tools''' ('''Alt''' + '''T''') > [https://support.mozilla.org/en-US/kb/Options%20window Options] and [http://kb.mozillazine.org/About:config about:config], and usually would also be empty of '''Extensions''' and themes ('''Appearance''') in '''Tools''' > '''Add-ons''', and their settings. Also, a new profile would have no previous stored website cache/cookies/data/preferences: '''Tools''' > [https://support.mozilla.org/en-US/kb/Clear%20Recent%20History '''Clear Recent History'''].
    [https://support.mozilla.org/en-US/kb/Profiles?s=profile&r=2&e=sph&as=s Profiles Howto]
    [http://kb.mozillazine.org/Profile_folder_-_Firefox Profile Folder & Files]

  • HOW TO - Create new from clipboard and process multiple files - please help

    Need help - have new version of photoshop on trial only ATM...
    Want to know - HOW TO:
    1. Create new from clipbaord
    2. Process multiple files
    Please help.

    For clipboard copy, I start with File > New and the size will be set to what's in the clipboard. Then once the new file is opened, Edit > Paste will place the clipboard contents as a layer in the new document.
    You must remember to use the command Layer > Flatten Image of you want to save as jpeg or any other file format that doesn't support layers.
    For processing multiple files,
    File > Automate > Batch or
    File > Scripts > Image Processor...
    Check the User guide or google information for those commands if you have specific needs.
    Gene

  • Uloading ebook using iProducer rec'd error: ERROR ITMS-9000: "Unable to parse nav file: toc.ncx" at Book. I don't understand and need help fixing it. Please Help

    Uloading ebook using iProducer rec'd error: ERROR ITMS-9000: "Unable to parse nav file: toc.ncx" at Book. I don't understand and need help fixing it. Please Help if you've the knowledge.
    Many Thanks

    Yep, i just did it again. The entire scroll-bar widget, complete with formatted text, graphics, etc., pasted itself nicely in another book. Two different files, the same widget.
    I use the scroll-bar widgets for most of my texts. (I have audio buttons on the side, and the scripts are within the widget, to the side). My only text is within widgets, and text boxes, naturally. 
    I am following your recommendation: cleaning files, etc. I am remaking the book anew. I need to convince the EPUB bot or whatever that my file looks and works nicely on all my devices. You would expect an error message when previewing the book: 'Hey Amigo, your file is flawed, stop working on it, and get back to the drawing board." Should be able to try again next Monday.

  • I need help organising my iPhoto please

    Can someone help me with my iPhoto.
    I have 14,400 photos in my iPhoto library.
    I have albums which contain the photos from the library,as I assumed once you created an album it would eliminate them from the library.
    Consequently I have lots of albums with what I thought was trying to was create some order ...but instead it's left me with photos everywhere.
    To create more dilema,I lost my hard-drive a few years ago and had not backed up any photos(5 years worth)....luckily for me my brother had backed up some and put them back into iPhoto for me but for some reason I now have 3 and 4 of the same photo.
    To make it more annoying the photos whilst there may be 3 of the same they are all different pixel sizes?Not sure how this happened?
    I've also got 3,300 photos in trash that I'm too scared to delete incase I don't have that exact photo in the library.
    Is there any easy way to sort this out,because the problem is getting worse as I try to create order?
    Is it possible to organize them all into folders that way I can delete them from the library and trash ?
    Thanks in advance

    leonieDF Hamburg, Germany
    Re: I need help organising my iPhoto please 
    Apr 6, 2013 9:07 AM (in response to flyinghostie)
    Would you mind to clarify a few points, please?
    I have 14,400 photos in my iPhoto library.
    o.k.
    I have albums which contain the photos from the library,as I assumed once you created an album it would eliminate them from the library.
    Consequently I have lots of albums with what I thought was trying to was create some order ...but instead it's left me with photos everywhere.
    That part is not clear to me.
    What kind of albums are you talking about? Do you mean iPhoto albums as seen in the "Albums" section of the source list?
    Yes the albums are contained in the Albums section
    as I assumed once you created an album it would eliminate them from the library.
    Albums will index and organize the photos in your library, but not store them and not remove them from the library. All photos need to be contained in an event. When you are referring to "library", are you referring to your iPhoto library or to the "Library" section in the source list in the iPhoto window?
    Yes the library I'm referring to is the Iphoto library.I do have Events also...will organising Events take them out of my Libraray?
    .but instead it's left me with photos everywhere.
    Perhaps you are confused by iPhoto showing you different views of the same photos.
    The top part of the source list "Library" gives you access to all your photos based on the events, as list of all "Photos", organized by the Faces, or organized by the Places. You can access the same photos in four different ways.
    The "Recent" section gives you access based on the date; but again you will see the very same photos, only grouped differently.
    These are the access paths predefined by iPhoto. The "Albums" section and "Projects" section will give you additional custom structures to retrieve your photos, the access structure you define yourself. But it will not remove the default organisation created by iPhoto, only supplement it with your own custom structures.
    To make it more annoying the photos whilst there may be 3 of the same they are all different pixel sizes?Not sure how this happened?
    Now, this is probably caused by the way you reimported your photos into your new library. When you take the folders from an iPhoto library and simply import all folders, you will import each photo in three different sizes, for the library contains thumbnails, previews, and full size original image files and versions.
    Would it be possible for you to repeat the import step from the backup your brother has made for you? It might be easier to sort your photos in the finder by size and only to import the full size image files, then to do that manually. What is the backup like, that your brother has made? Is it an iPhoto library or a folder containing photos and folders of your old iPhoto library?
    I'm not sure how my brother saved the photos as it's been years since he re imported them for me,I'd rather do this myself than trouble him again.I've thought maybe I can set up a folder on my desktop and drag all the main photos from the library into there,then delete iPhoto and start all over again?
    But before you proceed with deleting photos that you are not sure about, create a backup of the library, so you will be safe, if you accidentally delete too much.
    Regards
    Léonie

  • My Mac was updated to Ÿosemite OS and since then the PS5 software doesn't open. I need help on this subject please.

    My Mac was updated to Ÿosemite OS and since then the PS5 software doesn't open. I need help on this subject please.
    They error message I get is "An unexpected and unrecoverable problem has occurred. Photoshop will now exit."
    This only started after I upgraded my OS to Yosemite.

    The upgrade has been know to break Photoshop CS5 installs. An Uninstall/Reinstall may be necessary.

  • URGENT!!!  Please help~ Process Multiple Files says folder empty

    When I try to use the Process Multiple Files feature, it is giving me a message saying that the process was stopped or cancelled. Press continue or stop.  When I click continue, it say that the folder is empty.  It is not empty.    This is  what I use all the time to put my watermark on my photos.  I've never had a problem with it before.  Any suggestions?  Please

    Thank you for responding.    I am using Windows 8.  Since posting this about Process Multiple Images, I have noticed that PSE is not even opening images.  It will open the File>OPEN window, and act like it is going to import the image for about 1 second.  Then......nothing????   Any suggestions?

  • Need Help-SOA 11g File Adapter unable to delete input file and its crashing

    Hi All
    Please find the details below:
    1. We have created a simple SOA composite to Read file from an input directory, archive the file in an archive directory using Inbound File Adapter Read
    and then use Outbound File Adapter Write to move the file to a output directory.
    2. File Adapter needs to delete the file after successful read/retrieval.
    3. We are using the "Use Trigger File" for invoking the file adapter. This is a new feature in SOA 11g
    4. Also we are using the option of reading the file as an attachment as we are not doing any transformation in the composite
    Issue Details_
    1. When the trigger file is put in the input directory for the first time, the File Adapter reads the file, archives it and moves it to the output directory
    2. However it does not delete the input file from the input directory and raises Fatal Exception mentioned below:
    [*2011-01-12T16:55:48.639+05:30] [soa_server1] [WARNING] [] [oracle.soa.adapter] [tid: weblogic.work.j2ee.J2EEWorkManager$WorkWithListener@19c243d]*
    [userId: <anonymous>] [ecid: 0000IptyLrL9_aY5TrL6ic1DBOS_000009,0] [APP: soa-infra] File Adapter FileAdapterTriggerFilePOC PostProcessor::
    Delete failed, the operation will be retried for max of [0] times
    [2011-01-12T16:55:48.639+05:30] [soa_server1] [WARNING] [] [oracle.soa.adapter] [tid: weblogic.work.j2ee.J2EEWorkManager$WorkWithListener@19c243d]
    [userId: <anonymous>] [ecid: 0000IptyLrL9_aY5TrL6ic1DBOS_000009,0] [APP: soa-infra] File Adapter FileAdapterTriggerFilePOC [[
    BINDING.JCA-11042
    File deletion failed.
    File deletion failed.
    File : C:\Dibya\AttachmentTest\InputDir\TestFile3.txt could not be deleted.
    Delete the file and restart server. Contact oracle support if error is not fixable.
    If any one has faced similar issues, kindly provide pointers on how to resolve it.
    Regards,
    Dibya

    Hi,
    Using the file adapter, you can poll from multilple locations...
    Keep the following property in your .jca file
    <property name="DirectorySeparator" value="," />
    While giving the path in File Adapter configuration, keep comma and give the next location....then the file will be picked up from the locations you gave....
    Hope this helps...
    Thanks,
    N

  • Need help with connecting file inputs to arrays

    In this assignment I have a program that will do the following: display a list of names inputed by the user in reverse order, display any names that begin with M or m, and display any names with 5 or more letters. This is all done with arrays.
    That was the fun part. The next part requires me to take the names from a Notepad file, them through the arrays and then output them to a second Notepad file.
    Here is the original program: (view in full screen so that the code doesn't get jumbled)
    import java.io.*;       //Imports the Java library
    class progB                    //Defines class
        public static void main (String[] arguments) throws IOException
            BufferedReader keyboard;                                  //<-
            InputStreamReader reader;                                 //  Allows the program to
            reader = new InputStreamReader (System.in);               //  read the the keyboard
            keyboard = new BufferedReader (reader);                  //<-
            String name;                 //Assigns the name variable which will be parsed into...
            int newnames;               //...the integer variable for the amount of names.
            int order = 0;              //The integer variable that will be used to set the array size
            String[] array;             //Dynamic array (empty)
            System.out.println (" How many names do you want to input?");   //This will get the number that will later define the array
            name = keyboard.readLine ();
            newnames = Integer.parseInt (name);                                         // Converts the String into the Integer variable
            array = new String [newnames];                                               //This defines the size of the array
            DataInput Imp = new DataInputStream (System.in);       //Allows data to be input into the array
            String temp;                                       
            int length;                                                                  //Defines the length of the array for a loop later on
                for (order = 0 ; order < newnames ; order++)                                //<-
                {                                                                           //  Takes the inputed names and
                    System.out.println (" Please input name ");                            //  gives them a number according to
                    temp = keyboard.readLine ();                                           //  the order they were inputed in
                    array [order] = temp;                                                  //<-
                for (order = newnames - 1 ; order >= 0 ; order--)                                //<-
                {                                                                                //  Outputs the names in the reverse 
                    System.out.print (" \n ");                                                   //  order that they were inputed
                    System.out.println (" Name " + order + " is " + array [order]);             //<-
                for (order = 0 ; order < newnames ; order++)                                  //<-
                    if (array [order].startsWith ("M") || array [order].startsWith ("m"))     //  Finds and outputs any and all
                    {                                                                         //  names that begin with M or m
                        System.out.print (" \n ");                                            //
                        System.out.println (array [order] + (" starts with M or m"));         //
                    }                                                                         //<-
                for (order = 0 ; order < newnames ; order++)                                            //<-
                    length = array [order].length ();                                                   //
                    if (length >= 5)                                                                    //  Finds and outputs names
                    {                                                                                  //  with 5 or more letters
                        System.out.print (" \n ");                                                      //
                        System.out.println ("Name " + array [order] + " have 5 or more letters ");      //<-
    }The notepad file contains the following names:
    jim
    laruie
    tim
    timothy
    manny
    joseph
    matty
    amanda
    I have tried various methods but the one thing that really gets me is the fact that i can't find a way to connect the names to the arrays. Opening the file with FileInputStream is easy enough but using the names and then outputing them is quite hard. (unless i'm thinking too hard and there really is a simple method)

    By "connect", do you just mean you want to put the names into an array?
    array[0] = "jim"
    array[1] = "laruie"
    and so on?
    That shouldn't be difficult at all, provided you know how to open a file for reading, and how to read a line of text from it. You can just read the line of text, put it in the array position you want, until the file is exhausted. Then open a file for writing, loop through the array, and write a line.
    What part of all that do you need help with?

  • Need Help on ERMS(Urgent Please)

    Hi CRM Experts,
    Please help me on following Queris.
    1)can we place incoming email into categories/queues/pools based on email address, keywords, and/or rules?
    2)allow email to be manually moved between one queue and another?
    3)ability to assign multiple age thresholds to categories as a way of providing service level goals?
    4)can agent able to manually route the Email to another user?
    5)ability to define how long the user can hold the email without activity before returning it to the Queue?
    6)can we allow agents to manually pull any email from the Queue(as long they have been granted access)?
    7)Ability to perform a "bulk-resolution" or develop a relationship between the emails so that only one instance needs to be resolved?
    Please provide me solutions for above mentioned.
    Points will be rewarded.
    Thanks in Advance
    Sree

    Hi and Welcome to the Forums!
    Wow -- I've never seen that screen. Not at all sure what it even means. But, here's a process that I once found for recovering a bricked device...I've never had to use it, so I can't vouch for it's correctness...but at this point, what have you got to lose?
    http://adlen45.activeboard.com/index.spark?forumID=123568&p=3&topicID=18834966
    Hope it helps.
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Need help printing tiff files

    I have written some code that prints any file that can be opened using JAI and the ImageIO Tools. The code works good for me but I have some special cases where I am having some difficulty. Some files I need to print are TIFF files with many pages. Some are compressed using Fax Group 4 encoding and others are compressed using OLD jpeg-in-tiff. I can read and print the files just fine, but it takes about 2 seconds to print each page. Also the spooling data for 88 pages is 900 MB in size. Printing the same files using IrfanView takes <1 seconds and the spool file is much smaller (equivalent to the size of the uncompressed tiff) The speed and size issues are problems for me because I am working on a print web service. My code to render each page is below. So far I have tried rendering hints and such to increase speed, but I think the problem is that when I read the image it takes up a lot of space in memory.
    Here is the overall requirements for what I am doing: A use will request that the server print a set of files (mixed image formats, restricted to TIFF, JPEG, and GIF) be printed to specific printer as a single print job. They can specify copies and collation only. The service will open each file in order and send its data to the printer. I have created a custom class that implements the Printable interface to handle the multiple files. The class below is created for each file and handles the printing of the image file.
    I am using JDK 1.4.2 and WebSphere. I am stuck with these options b/c I have to use some IBM API's (IBM Content Manager 8.3) that are not compatible with 1.5 or higher.
    Is there any way to speed up my code. Possibly load the image differently?
    import java.awt.Graphics2D;
    import java.awt.RenderingHints;
    import java.awt.geom.AffineTransform;
    import java.awt.image.BufferedImage;
    import java.awt.print.PageFormat;
    import java.awt.print.Printable;
    import java.awt.print.PrinterException;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    import javax.imageio.ImageReader;
    import javax.imageio.stream.FileImageInputStream;
    import javax.imageio.stream.ImageInputStream;
    public class ImagePrinter2 implements Printable
       public static final int PAPER_SIZE_LETTER = 0;
       public static final int PAPER_SIZE_LEGAL = 1;
       private final ImageReader reader;
       private final int _pageCount;
       private final File imageFile;
       private int _pageOffset;
       public ImagePrinter2(File imageFile) throws IOException
          this.imageFile = imageFile;
          ImageInputStream fis = new FileImageInputStream(this.imageFile);
          reader = (ImageReader) ImageIO.getImageReaders(fis).next();
          reader.setInput(fis);
          _pageCount = reader.getNumImages(true);
       public int print(java.awt.Graphics g, java.awt.print.PageFormat pf, int pageIndex)
          throws java.awt.print.PrinterException
          BufferedImage image = null;
          int currentPage = pageIndex - getPageOffset();  //pageIndex is for the overall job, I need the page in this file
          int imgWidth = 0, imgHeight = 0;
          int drawX = 0, drawY = 0;
          double scaleRatio = 1;
          try
             image = reader.read(currentPage);
             imgWidth = image.getWidth();
             imgHeight = image.getHeight();
          catch (IndexOutOfBoundsException e)
             return NO_SUCH_PAGE;
          catch (IOException e)
             throw new PrinterException(e.getLocalizedMessage());
          if (imgWidth > imgHeight)
             pf.setOrientation(PageFormat.LANDSCAPE);
          else
             pf.setOrientation(PageFormat.PORTRAIT);
          Graphics2D g2 = (Graphics2D) g;
          g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
          g2.translate(pf.getImageableX(), pf.getImageableY());
          g2.setClip(0, 0, (int) pf.getImageableWidth(), (int) pf.getImageableHeight());
          scaleRatio =
             (double) ((imgWidth > imgHeight)
                ? (pf.getImageableWidth() / imgWidth)
                : (pf.getImageableHeight() / imgHeight));
          //check the scale ratio to make sure that we will not write something off the page
          if ((imgWidth * scaleRatio) > pf.getImageableWidth())
             scaleRatio = (pf.getImageableWidth() / imgWidth);
          else if ((imgHeight * scaleRatio) > pf.getImageableHeight())
             scaleRatio = (pf.getImageableHeight() / imgHeight);
          //center image
          if (scaleRatio < 1)
             drawX = (int) ((pf.getImageableWidth() - (imgWidth * scaleRatio)) / 2);
             drawY = (int) ((pf.getImageableHeight() - (imgHeight * scaleRatio)) / 2);
          else
             drawX = (int) (pf.getImageableWidth() - imgWidth) / 2;
             drawY = (int) (pf.getImageableHeight() - imgHeight) / 2;
          AffineTransform at = AffineTransform.getTranslateInstance(drawX, drawY);
          if (scaleRatio < 1)
             at.scale(scaleRatio, scaleRatio);
          g2.drawRenderedImage(image, at);
          g2.dispose();
          image = null;
          return PAGE_EXISTS;
        * <br><br>
        * Created By: TSO1207 - John Loyd
        * @since version XXX
        * @return
       public int getPageCount()
          return _pageCount;
        * <br><br>
        * Created By: TSO1207 - John Loyd
        * @since version XXX
        * @return
       public int getPageOffset()
          return _pageOffset;
        * <br><br>
        * Created By: TSO1207 - John Loyd
        * @since version XXX
        * @param i
       protected void setPageOffset(int i)
          _pageOffset = i;
          * Release the reader resources
          * <br><br>
          * Created By: TSO1207 - John Loyd
          * @since version XXX
       public void destroy()
              try
                   ((ImageInputStream) reader.getInput()).close();
              catch (Exception e)
              reader.reset();
          reader.dispose();
        * Helps release memory used when printing (seems to be a 1.4.2 thing)
        * <br><br>
        * Created By: TSO1207 - John Loyd
        * @since version XXX
       public void reset() throws FileNotFoundException, IOException
          try
             ((ImageInputStream) reader.getInput()).close();
          catch (Exception e)
          reader.reset();
          ImageInputStream fis = new FileImageInputStream(imageFile);
          reader.setInput(fis);
    }

    I found a couple of issues. One was related to code the other to IBM. AS for the code I found an article about drawing scaled images here: http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html which was quite useful. My updated code is below. The second issues is that the JRE I am using is the IBM Websphere 5.1 JRE which pretty much sicks. I tested using a Sun statndard 1.4.2 JRE and the print was 5 times faster. Now I am looking to find a way around that issue, but it is not a questions for this form.
    public int print(java.awt.Graphics g, java.awt.print.PageFormat pf, int pageIndex)
          throws java.awt.print.PrinterException
          BufferedImage image = null;
          int currentPage = pageIndex - getPageOffset();  //pageIndex is for the overall job, I need the page in this file
          int imgWidth = 0, imgHeight = 0;
          int drawX = 0, drawY = 0;
          double scaleRatio = 1;
          try
             image = reader.read(currentPage);
             imgWidth = image.getWidth();
             imgHeight = image.getHeight();
          catch (IndexOutOfBoundsException e)
             return NO_SUCH_PAGE;
          catch (IOException e)
             throw new PrinterException(e.getLocalizedMessage());
          if (imgWidth > imgHeight)
             pf.setOrientation(PageFormat.LANDSCAPE);
          else
             pf.setOrientation(PageFormat.PORTRAIT);
          Graphics2D g2 = (Graphics2D) g;
          g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
          g2.translate(pf.getImageableX(), pf.getImageableY());
          g2.setClip(0, 0, (int) pf.getImageableWidth(), (int) pf.getImageableHeight());
          scaleRatio =
             (double) ((imgWidth > imgHeight)
                ? (pf.getImageableWidth() / imgWidth)
                : (pf.getImageableHeight() / imgHeight));
          //check the scale ratio to make sure that we will not write something off the page
          if ((imgWidth * scaleRatio) > pf.getImageableWidth())
             scaleRatio = (pf.getImageableWidth() / imgWidth);
          else if ((imgHeight * scaleRatio) > pf.getImageableHeight())
             scaleRatio = (pf.getImageableHeight() / imgHeight);
          //find the scaled width and height
          int scaledWidth = imgWidth, scaledHeight=imgHeight;
          //center image
          if (scaleRatio < 1)
             drawX = (int) ((pf.getImageableWidth() - (imgWidth * scaleRatio)) / 2);
             drawY = (int) ((pf.getImageableHeight() - (imgHeight * scaleRatio)) / 2);
             //new code to set the scale
             scaledWidth = (int)(scaledWidth * scaleRatio);
             scaledHeight = (int)(scaledHeight * scaleRatio);
          else
             drawX = (int) (pf.getImageableWidth() - imgWidth) / 2;
             drawY = (int) (pf.getImageableHeight() - imgHeight) / 2;
    /*don't need transform
          /*AffineTransform at = AffineTransform.getTranslateInstance(drawX, drawY);
          if (scaleRatio < 1)
             at.scale(scaleRatio, scaleRatio);
          g2.drawRenderedImage(image, at);*/
          //use scale instance of draw image
          g2.drawImage(image, drawX, drawY, scaleWidth, scaleHeight, null);     
          g2.dispose();
          image = null;
          return PAGE_EXISTS;
       }Edited by: jloyd01 on Mar 7, 2008 1:35 PM

  • Need help with case structures- please help :)

    Hey all.
    I'm currently trying to program a infrared furnace. I'm setting a temperature, subtracted my set temperature from the actual temperature (thermocouple hooked up to SCB-68), and voltage is being sent to the controller of the furnace accordingly. However, I need to hold the set temperature for a certain amount of time. I need help programming this: when the VI reads the set temperature from the thermocouple, it results in a timer running down. When the timer runs down to 0, the While Loop ends. I'm thinking case structures is most appropriate, but if you have a better suggestion, please let me know.
    Thanks

    You should probably implement a state machine.
    The state machine would keep track of the temperature and making ajustments on a timely basis.
    There is a template of a state machine is you select under the File menu > New > From Template.
    You can also look under Help > Find Example > and do a search for state machine.
    There are lots of state machine examples on this forum, some of which may be quite useful.
    RayR

  • Need help with copying files onto external drive

    I need help! Trying to copy downloaded movie files from Vuze (which have downloaded successfully) and copy onto external hard drive to view them but it wont let me copy over to the external device. Any ideas how to fix this please???

    Can you explain the steps you used, and the error message (or symptom), that says the copy did not work? 

  • I would need help with the following please: I need to save some of my email on a disk. I was going to Print, then Save PDF but then I am stuck. Help please. Thanks. Elisabeth

    I would need help with saving some eamil messages to a disk to unclutter my email. How can I do this please?
    Thanks.
    Elisabeth

    Open the email and then from the File menu select Save As Rich Text Format. That'll save it to open in TextEdit. If you want a pdf then open the email and do command-p (Print) and then from the PDF drop down box lower left corner select Save as PDF.

  • I need help retrieving Microsoft files lost when upgrading to OSX Mavericks

    My daughter recently upgraded our Mac to the OSX Mavericks platform. Unfortunately, all of our Microsoft files, etc. are gone! I need to know how I can retrieve these files or if I can. I'm honestly not impressed with this new platform. I need help asap and your help is truly appreciated.

    You have to make the backup yourself. That's your only protection against file loss whether accidental or catastrophic. In fact you should have at least two of them - each done differently and on separate drives.
    If your files truly were "erased" then you can see if they can be recovered:
    General File Recovery
    If you stop using the drive it's possible to recover deleted files that have not been overwritten by using recovery software such as MAC Data Recovery, Data Rescue II, File Salvage or TechTool Pro.  Each of the preceding come on bootable CDs to enable usage without risk of writing more data to the hard drive.  Two free alternatives are Disk Drill and TestDisk.  Look for them and demos at MacUpdate or CNET Downloads. Recovery software usually provide trial versions that enable you to determine if the software would help before actually paying for it. Beyond this or if the drive has completely failed, then you would need to send the drive to a recovery service which is very expensive.
    The longer the hard drive remains in use and data are written to it, the greater the risk your deleted files will be overwritten.
    Also visit The XLab FAQs and read the FAQ on Data Recovery.
    Basic Backup
    For some people Time Machine will be more than adequate. Time Machine is part of OS X. There are two components:
    1. A Time Machine preferences panel as part of System Preferences;
    2. A Time Machine application located in the Applications folder. It is
         used to manage backups and to restore backups. Time Machine
         requires a backup drive that is at least twice the capacity of the
         drive being backed up.
    3. Time Machine requires a backup drive that is at least double the
         capacity of the drive(s) it backs up.
    Alternatively, get an external drive at least equal in size to the internal hard drive and make (and maintain) a bootable clone/backup. You can make a bootable clone using the Restore option of Disk Utility. You can also make and maintain clones with good backup software. My personal recommendations are (order is not significant):
      1. Carbon Copy Cloner
      2. Get Backup
      3. Deja Vu
      4. SuperDuper!
      5. Synk Pro
      6. Tri-Backup
    Visit The XLab FAQs and read the FAQ on backup and restore.  Also read How to Back Up and Restore Your Files. For help with using Time Machine visit Pondini's Time Machine FAQ for help with all things Time Machine.
    Although you can buy a complete external drive system, you can also put one together if you are so inclined.  It's relatively easy and only requires a Phillips head screwdriver (typically.)  You can purchase hard drives separately.  This gives you an opportunity to shop for the best prices on a hard drive of your choice.  Reliable brands include Seagate, Hitachi, Western Digital, Toshiba, and Fujitsu.  You can find reviews and benchmarks on many drives at Storage Review.
    Enclosures for FireWire and USB are readily available.  You can find only FireWire enclosures, only USB enclosures, and enclosures that feature multiple ports.  I would stress getting enclosures that use the Oxford chipsets especially for Firewire drives (911, 921, 922, for example.)  You can find enclosures at places such as;
      1. Cool Drives
      2. OWC
      3. WiebeTech
      4. Firewire Direct
      5. California Drives
      6. NewEgg
    All you need do is remove a case cover, mount the hard drive in the enclosure and connect the cables, then re-attach the case cover.  Usually the only tool required is a small or medium Phillips screwdriver.

Maybe you are looking for

  • Have Old Hard drive and want to move old data onto new hard drive in imac.

    I am trying to get my files off of an old hard drive. I have it hooked up through a sata drive. I am able to access all the programs but for whatever reason I am unable to access any of the files, i.e- 1,00's of pictures, videos, music, and documents

  • Plug-ins InDesign

    I have a problem opening a document in InDesign. I've been working on this document on an other computer and now I open it on my workcomputer to continue this document with the error: Cannot open. Please upgrade your plug-ins to their latest version

  • LAST QUESTION ABOUT MY CODE (promise)

    Here is my final code for the 6/49 lottery game (it's a more simplified version so don't mind that there is no Bonus Number) sorry for the long code... I'll just post my question here for those who don't want to go through all of this. I want to thro

  • Classic doesn't update or sync

    Several weeks ago, my Classic and iTunes stopped talking to each other.   I dock my iPod and iTunes does not update to show the podcasts that I watched during the day and the iPod does not auto sync and load the new shows that are in iTunes.  iTunes

  • JSP clear a buffer -- FLUSH ERROR

    Hai everybody! I've 3 jsp files. The First and the Second jsp file's will be forwarded to the Third jsp file when it completed certain process in each of the page. The problem that I faced is that, the First page can be forwarded to Third jsp file, b