File Chooser and Scanner/ PrintWriter

I'm trying to use the file chooser and scanner and printwriter together. How can I go about this?

import java.io.*;
import java.util.Scanner;
import javax.swing.JFileChooser;
* @author Originative
public class Test {
    JFileChooser jf=new JFileChooser(".");
    String fileName="";
    public static void main(String [] nix){
        Test t=new Test();
        t.Actor();
    public void Actor(){
        try{
            Scanner c=new Scanner(System.in);
            System.out.print("Enter 1 to Open JFileChooser : ");
            int k=c.nextInt();
            if(k==1){
                int val=jf.showOpenDialog(jf);
                if(val==JFileChooser.APPROVE_OPTION){
                    File fi=jf.getSelectedFile();
                    fileName=jf.getSelectedFile().toString();
                    PrintWriter pw = new PrintWriter(System.out, true);
                    pw.println(fileName);
            if(k!=1){
                System.out.println("Bye Bye  :)");
        catch(Exception d){
            System.out.println(d);
}A sample you can use in this way and many many many many others :)

Similar Messages

  • Combining File Chooser and this MP3 class

    Hello all,
    I was curious if anyone could help me figure out how to get a file to actually load once it is used with this code.
    I'm unfamiliar with how it works and I was hoping for an explanation on it.
    I wasn't sure if I had to have the program recgonize that I would like to load a mp3 or if it just would load it automatically...
    Essentially, I want to be able to load a mp3 if I use the file chooser.
    I can try to clarify my question more if anyone should need it.
    Thank you
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class List extends JPanel
                                 implements ActionListener {
        static private final String newline = "\n";
        JButton openButton, saveButton;
        JTextArea log;
        JFileChooser fc;
        public List() {
            super(new BorderLayout());
            //Create the log first, because the action listeners
            //need to refer to it.
            log = new JTextArea(5,20);
            log.setMargin(new Insets(5,5,5,5));
            log.setEditable(false);
            JScrollPane logScrollPane = new JScrollPane(log);
            //Create a file chooser
            fc = new JFileChooser();
            //Uncomment one of the following lines to try a different
            //file selection mode.  The first allows just directories
            //to be selected (and, at least in the Java look and feel,
            //shown).  The second allows both files and directories
            //to be selected.  If you leave these lines commented out,
            //then the default mode (FILES_ONLY) will be used.
            //fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
           // fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
            //Create the open button.  We use the image from the JLF
            //Graphics Repository (but we extracted it from the jar).
            openButton = new JButton("Open a File...",
                                     createImageIcon("images/Open16.gif"));
            openButton.addActionListener(this);
            //Create the save button.  We use the image from the JLF
            //Graphics Repository (but we extracted it from the jar).
            saveButton = new JButton("Save a File...",
                                     createImageIcon("images/Save16.gif"));
            saveButton.addActionListener(this);
            //For layout purposes, put the buttons in a separate panel
            JPanel buttonPanel = new JPanel(); //use FlowLayout
            buttonPanel.add(openButton);
            buttonPanel.add(saveButton);
            //Add the buttons and the log to this panel.
            add(buttonPanel, BorderLayout.PAGE_START);
            add(logScrollPane, BorderLayout.CENTER);
        public void actionPerformed(ActionEvent e) {
            //Handle open button action.
            if (e.getSource() == openButton) {
                int returnVal = fc.showOpenDialog(List.this);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    File file = fc.getSelectedFile();
                    //This is where a real application would open the file.
                    log.append("Opening: " + file.getName() + "." + newline);
                } else {
                    log.append("Open command cancelled by user." + newline);
                log.setCaretPosition(log.getDocument().getLength());
            //Handle save button action.
            } else if (e.getSource() == saveButton) {
                int returnVal = fc.showSaveDialog(List.this);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    File file = fc.getSelectedFile();
                    //This is where a real application would save the file.
                    log.append("Saving: " + file.getName() + "." + newline);
                } else {
                    log.append("Save command cancelled by user." + newline);
                log.setCaretPosition(log.getDocument().getLength());
        /** Returns an ImageIcon, or null if the path was invalid. */
        protected static ImageIcon createImageIcon(String path) {
            java.net.URL imgURL = List.class.getResource(path);
            if (imgURL != null) {
                return new ImageIcon(imgURL);
            } else {
                System.err.println("Couldn't find file: " + path);
                return null;
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
        private static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("FileChooserDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            JComponent newContentPane = new List();
            newContentPane.setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }The mp3 class that I've been playing around with...
    import java.io.BufferedInputStream;
    import java.io.FileInputStream;
    import javazoom.jl.player.Player;
    public class MP3 {
        private String filename;
        private Player player;
        // constructor that takes the name of an MP3 file
        public MP3(String filename) {
            this.filename = filename;
        public void close() { if (player != null) player.close(); }
        // play the MP3 file to the sound card
        public void play() {
            try {
                FileInputStream fis = new FileInputStream(filename);
                BufferedInputStream bis = new BufferedInputStream(fis);
                player = new Player(bis);
            catch (Exception e) {
                System.out.println("Problem playing file " + filename);
                System.out.println(e);
            // run in new thread to play in background
            new Thread() {
                public void run() {
                    try { player.play(); }
                    catch (Exception e) { System.out.println(e); }
            }.start();
    // test client
        public static void main(String[] args) {
            String filename = "C:\\FP\\1.mp3";
            MP3 mp3 = new MP3(filename);
            mp3.play();
    }

    Thanks for the link
    I've been looking over the sections and still confused with the code.
    It's obvious that I have to do something with this portion of the code:
    public void actionPerformed(ActionEvent e) {
        //Handle open button action.
        if (e.getSource() == openButton) {
            int returnVal = fc.showOpenDialog(FileChooserDemo.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = fc.getSelectedFile();
                //This is where a real application would open the file.
                log.append("Opening: " + file.getName() + "." + newline);
            } else {
                log.append("Open command cancelled by user." + newline);
    }I'm just not sure what.

  • File Choose And download

    Hello friends,
    i read answers to my previous questions and i realized that i
    should probably for the coming time will not use them (though i
    thought they were simple...).
    i want to do something very simple and if you could advise
    how it would be helpful.
    how can i have a page with list of few files (not in 1 place,
    but all on HDD), that user could choose with mouse some of them,
    and than to download them to his local hdd (its internal page to
    small group).
    thank you.

    you are't going to get helpful replies if you don't keep one
    subject in one
    thread. Asking the same question but not giving reference to
    previous
    replies means rehashing the same things.
    > the problem is that its many files, that i want them to
    choose from.
    >the files are in different locations and are constantly
    changing (there is no
    >way to track this...)
    three basic ways-
    Manual updating as documents are added.
    Changing the workflow so these documents are put into ONE
    specific folder,
    which has directory browsing enabled (set
    example.local/documents/ so it
    display folder contents)
    Dynamic page involving a script that reads the contents of
    specified folders
    and builds the page using that info. Assuming that it is a
    known list of
    places where these documents will be. What scripting is
    allowed on this
    intranet? asp/php/?? It is running on a webserver, yes?
    If the documents are added to random folders that contain
    similar files that
    they don't want linked, they need to change the workflow.
    Alan
    Adobe Community Expert, dreamweaver
    http://www.adobe.com/communities/experts/

  • Mac os 10.9.5--elements 10--go to file import and my scanner isn't listed

    mac os 10.9.5--elements 10--go to file>import and scanner not gown

    The members of the Photoshop Elements forum can best answer and followup on your question.
    Gene

  • File Chooser + Loops

    I've been at this sadly for almost 8 hours now....here is what my program is suppose to accomplish....yet it's not and I cannot for the life of me figure out what to do
    1. Prompt the user to browse to a file.
    If the user browses to a file, selects it and hits open it will open a JTextArea displaying the text within the file. When the JTextArea closes the program should terminate.
    2. When the user is prompted and selects CANCEL a "catch" statement should then throw a pop-up window telling the user they they did not select a file. When they aknowledge the pop-up they should be prompted to browse to a file. If they continue to hit cancel it should continue to run them through the loop. HOWEVER, when they finally browse and select a file it should work just as I stated in #1.
    3. The same explaination as #2 goes for the catch statement when a users file is unable to be found.
    I have exhausted all online resources, my book, my teacher to try and find how to properly formulate my code and loop to work correctly. This is the best I have come up with.
    It does everything except for one major problem. When a user finally does select a file after running through the loop, it will not display anything.
    Someone please...break this down for me or even edit my code so that I can visually see what and where things go.....I know the reason nothing is being displayed is because in the catch statement I am not stating what to do after the user selects a file....but I dont even think i'm doing this right....sigh
    //  DisplayFile.java       Author: Lewis/Loftus
    //  Demonstrates the use of a file chooser and a text area.
    import java.util.Scanner;
    import java.io.*;
    import javax.swing.*;
    public class FileDisplay
       public static void main (String[] args) throws IOException
          JFrame frame = new JFrame ("Display File");
          frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
          JTextArea ta = new JTextArea (20, 30);
          JFileChooser chooser = new JFileChooser();
          int status = chooser.showOpenDialog (null);
         do
             try {
                File  file = chooser.getSelectedFile();
                Scanner scan = new Scanner(file);
                String info = "";
                while (scan.hasNext())
                info +=scan.NextLine() + "\n";
                 ta.setText (info);
              catch (FileNotFoundException exception)
                   JOptionPane.showMessageDialog (null, "File could not be found, click ok to try again");
    chooser.showOpenDialog (null);
              catch (NullPointerException exception)
                   JOptionPane.showMessageDialog (null, "You did not choose a file, click ok to try again");
    chooser.showOpenDialog (null);
         } while (status !=JFileChooser.APPROVE_OPTION);
          frame.getContentPane().add (ta);
          frame.pack();
          frame.setVisible(true);
    }

    No. That's not an assignment statement. To change the value of the variable "status", you need an assignment statement. If being told that isn't helpful, then I suggest you go and talk to your teacher. You won't be able to get anywhere here by asking questions like that.

  • File chooser Very basic

    Hey , i have a simple GUI, a button and a text box. When we click the button a file chooser will appear and we are able to select the folder/file we like.
    My question is, when we click on the button and when the File chooser window appears, i wont it to display the file structure in D:/ShanesFolder/admin/ . how do i code this.
    i ftried using
    FileFilter filter = new FileNameExtensionFilter("c files", "c"); but it filters files only.
    So how can i filter folders in the file chooser, and change the folder location to D:/ShanesFolder/admin/ instead of the default location of the file chosser.

    RTFM
    Do you see anything here that you think might be helpful? [http://java.sun.com/javase/6/docs/api/javax/swing/JFileChooser.html]

  • How do a scan a file from my scanner and make it a PDF. . . . I do not see this choice in the Adobe program?

    How do a scan a file from my scanner and make it a PDF. . . . I do not see this choice in the Adobe program?
    In the past I would simply place a copy of the document on my scanner, then selected create PDF from scanner.  However, there is now no create PDF from scanner alternative, option or choice.  The only option available is selected file to convert to PDF.  what am I to do?

    That would have been a function of your scanning software. Adobe Reader is only used to view the pdf that your scanning software created.

  • Choosing and copying in the pdf file

    From the security settings of the file, I see that the pdf author has allowed the copying, but I can't choose and copy. How can I do it?

    A scan is basically an image; you can't select any (or all) text on it.
    The only way to get text out of a scanned image is to process it with text recognition (OCR), which is available in Acrobat or the Adobe PDF Pack service.

  • I can not download any files using Safari ? when I choose to download application file the URL include the file name and stop responding. Any help??

    I can not download any files using Safari ? when I choose to download application file the URL include the file name and stop responding. Any help??

    Please read this whole message before doing anything.
    This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it.
    Step 1
    The purpose of this step is to determine whether the problem is localized to your user account.
    Enable guest logins* and log in as Guest. For instructions, launch the System Preferences application, select Help from the menu bar, and enter “Set up a guest account” (without the quotes) in the search box.
    While logged in as Guest, you won’t have access to any of your personal files or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
    Test while logged in as Guest. Same problem(s)?
    After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    *Note: If you’ve activated “Find My Mac” or FileVault in Mac OS X 10.7 or later, then you can’t enable the Guest account. The Guest login created by “Find My Mac” is not the same. Create a new account in which to test, and delete it, including its home folder, after testing.
    Step 2
    The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode* and log in to the account with the problem. The instructions provided by Apple are as follows:
    Be sure your Mac is shut down.
    Press the power button.
    Immediately after you hear the startup tone, hold the Shift key. The Shift key should be held as soon as possible after the startup tone, but not before the tone.
    Release the Shift key when you see the gray Apple icon and the progress indicator (looks like a spinning gear).
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    *Note: If FileVault is enabled under Mac OS X 10.7 or later, you can’t boot in safe mode.
    Test while in safe mode. Same problem(s)?
    After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of steps 1 and 2.

  • File Chooser is displaying names of the Files and Directories as boxes

    Hi All,
    Actually i am working on an application in which i have the requirement to internationalize the File Chooser in All Operating Systems. The application is working properly for all languages on MAC OS, but not working properly for the language Telugu on both the Ubuntu and Windows OS. The main problem is, when i try to open the File Chooser after setting the language to TELUGU all the labels and buttons in the File Chooser are properly internationalized but names of Files and directories in the File Chooser are displaying as boxes.
    So please provide your suggestions to me.
    Thanks in Advance
    Uday.

    I hope this can help you:
    package it.test
    import java.awt.BorderLayout;
    import java.awt.Frame;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.Locale;
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JFileChooser;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    import javax.swing.UIManager;
    * @author Alessandro
    public class Test extends JDialog {
         private JFileChooser fc = null;
         private Frame bfcParent = null;
         public Test(Frame parent, boolean modal) {
              super(parent, modal);
              this.bfcParent = parent;
              if (fc == null) {
                   fc = new JFileChooser();
                   fc.setAcceptAllFileFilterUsed(false);
                   fc.setLocale(Locale.ITALIAN);//i think you should use english
                   //these are in telugu
                   UIManager.put("FileChooser.openDialogTitleText", "Open Dialog");
                   UIManager.put("FileChooser.saveDialogTitleText", "Save Dialog");
                   UIManager.put("FileChooser.lookInLabelText", "LookIn");
                   UIManager.put("FileChooser.saveInLabelText", "SaveIn");
                   UIManager.put("FileChooser.upFolderToolTipText", "UpFolder");
                   UIManager.put("FileChooser.homeFolderToolTipText", "HomeFolder");
                   UIManager.put("FileChooser.newFolderToolTipText", "New FOlder");
                   UIManager.put("FileChooser.listViewButtonToolTipText", "View");
                   UIManager.put("FileChooser.detailsViewButtonToolTipText", "Details");
                   UIManager.put("FileChooser.fileNameHeaderText", "Name");
                   UIManager.put("FileChooser.fileSizeHeaderText", "Size");
                   UIManager.put("FileChooser.fileTypeHeaderText", "Type");
                   UIManager.put("FileChooser.fileDateHeaderText", "Date");
                   UIManager.put("FileChooser.fileAttrHeaderText", "Attr");
                   UIManager.put("FileChooser.fileNameLabelText", "Label");
                   UIManager.put("FileChooser.filesOfTypeLabelText", "filesOfType");
                   UIManager.put("FileChooser.openButtonText", "Open");
                   UIManager.put("FileChooser.openButtonToolTipText", "Open");
                   UIManager.put("FileChooser.saveButtonText", "Save");
                   UIManager.put("FileChooser.saveButtonToolTipText", "Save");
                   UIManager.put("FileChooser.directoryOpenButtonText", "Open Directory");
                   UIManager.put("FileChooser.directoryOpenButtonToolTipText", "Open Directory");
                   UIManager.put("FileChooser.cancelButtonText", "Cancel");
                   UIManager.put("FileChooser.cancelButtonToolTipText", "Cancel");
                   UIManager.put("FileChooser.newFolderErrorText", "newFolder");
                   UIManager.put("FileChooser.acceptAllFileFilterText", "Accept");
                   fc.updateUI();
         public int openFileChooser() {
              fc.setDialogTitle("Open File");
              fc.resetChoosableFileFilters();
              int returnVal = 0;
              fc.setDialogType(JFileChooser.OPEN_DIALOG);
              returnVal = fc.showDialog(this.bfcParent, "Apri File");
              //Process the results.
              if (returnVal == JFileChooser.APPROVE_OPTION) {
                   System.out.println("Hai scelto di aprire un file");
              } else {
                   System.out.println("hai annullato l'apertura");
              return returnVal;
         private static void createAndShowGUI() {
              JFrame frame = new JFrame("FileChooser");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JPanel jp = new JPanel(new BorderLayout());
              JButton openButton = new JButton("Open File");
              final Test test = new Test(frame, true);
              openButton.addActionListener(new ActionListener() {
                   @Override
                   public void actionPerformed(ActionEvent e) {
                        test.openFileChooser();
              openButton.setEnabled(true);
              jp.add(openButton, BorderLayout.AFTER_LAST_LINE);
              //Add content to the window.
              frame.add(jp);
              //Display the window.
              frame.pack();
              frame.setVisible(true);
         public static void main(String[] args) {
              //Schedule a job for the event dispatch thread:
              //creating and showing this application's GUI.
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        //Turn off metal's use of bold fonts
                        createAndShowGUI();
    }bye ale

  • I am sending a single-page poster in Illustrator to a commercial printer. There are several placed graphics and I want to choose the correct file-type to keep my Illustrator file nice and small.

    I am sending a single-page poster in Illustrator to a commercial printer. There are several placed graphics and I want to choose the correct file-type to keep my Illustrator file nice and small.

    Printers like PDFs, but you should consult with the print vendor before you save the file in any particular format.  Each vendor is different and have an established workflow.  They may not accept JPGs.  If the poster prints offset, you will need to supply the appropriate resolution per their request or what they require. If the poster is large format or grand format, then they will or should know what resolution is appropriate.  However, large format inkjet only requires 144-150ppi at 100% final size.  Try to get in the habit of consulting with the print vendor early on so you end up supplying what is needed.

  • WHen I choose an album, upload a file(s), just as the file(s) is uploaded the file I have chosen disappears and I am asked to choose album again. If I ignore this and drag a file onto the sceneline, I get the "where is the file " message" and when click o

    WHen I choose an album, upload a file(s), just as the file(s) is uploaded the file I have chosen disappears and I am asked to choose album again. If I ignore this and drag a file onto the sceneline, I get the "where is the file " message" and when click on the file it is looking for I get the message "This type of file is not supported, or the required codec is not installed". I have made many little films before but always have this problem now. Any suggestions?

    Margaret
    Although we are continents apart - Australia (Perth) vs North America (US), we will not let time zones interfere with getting your Premiere Elements 8.0/8.0.1 working.
    1. The usual Premiere Elements 8 drill.
    a. Are the automatic features of Background Rendering and AutoAnalzyer turned Off?
    For Background Rendering, see Premiere Elements workspace Edit Menu/Preferences/General. For AutoAnalzyer, see Elements Organizer workspace Edit Menu/Preferences/AutoAnalyzer Options.
    b. Are you running the program from the 8.0.1 Update? If not, see Help Menu/Update?
    c. Do you have the latest version of QuickTime installed on your computer with Premiere Elements 8.0/8.0.1?
    Apple - QuickTime - Download
    2. The usual computer drill....for your Windows XP 32 bit (SP3, I presume)
    a. Is computer opitimized, defragmented, etc.
    CCleaner - PC Optimization and Cleaning - Free Download
    b. Are you running your computer from a User Account with Administrative Privileges? That is important for Premiere Elements 8 as well as for its
    required QuickTime. In addition, right click the computer desktop icon for Premiere Elements 8 and select and apply Run As Administrator.
    3. Project Specifics
    For now, import your source media into the project from the computer hard drive using the project's Get Media/Files and Folders. Leave the Elements Organizer and Albums out of the equation for now. We will circle back to it soon after we decide everything else is working as it should be.
    a. You need to set a project preset. And, that project preset should match the properties of your source media. So important to know properties of source media.
    b. When you import your source media into a project you will get a red line over its content if the project preset is not a match - either because you set the wrong one or the program does not have a match for your particular video. That red line means that you are not seeing the best possible preview of what is being played back in the Edit area monitor. To get the best possible preview, you hit the Enter key of the computer main keyboard to get a rendered Timeline (red line goes from red to green after this type of rendering). That green line over your rendered Timeline indicates that you are now getting the best possible preview. This is solely a preview thing. Longer story, but I will leave it at that for now.
    c. Check Edit Menu/Preferences/Scratch Disks to assure that those Scratch Disks are being saved to a computer hard drive location with enough free space to accept them. Make sure that you do not have pile ups of previews files, conformed audio files, and conformed video files.
    See Local Disk C\Documents and Settings\Owner\My Documents\Adobe\Premiere Elements\9.0
    Never move, delete, or rename source files after they have been imported into a project which has been saved/closed. Otherwise, nasty media disconnect problems. You have only copies of media in Premiere Elements. The originals are on the hard drive, and the project must trace back to the originals where they were at import.
    Based on the above, try to start a new project. But, let me know ahead of time what you will be importing into the project. I am looking for
    Video
    video compression
    audio compression
    frame size
    frame rate
    interlaced or progressive
    pixel aspect ratio
    If you do not know, we could try to get that type of information from knowing the brand/model/settings for the camera that recorded the video.
    Photos
    Pixel dimensions and how many photos?
    Lots and lots of details, but eventually they all mellow into one workflow that you can customize for your projects.
    Please do not hesitate to ask questions or to ask for clarification. We can go at whatever pace you feel comfortable with.
    ATR

  • Printer and scanner calibration

    Hi,
    I have a DTP94 colorimeter (AKA Monaco XR Pro), a Canon iP1600 printer and an Epson Perfection 4990 Photo scanner (with built-in slide/negative scanner). What do I need to buy, in terms of hardware and software, to calibrate the printer and scanner?
    S.
    EDIT: I also have the latest ColorEyes Display Pro software demo installed. Does this apply at all?
    Message was edited by: SiRGadaBout

    Monaco's EZColor software, supplied with the DTP94, actually offers scanner and printer profiling, but only in versions 2.50 upwards
    I hadn't mentioned that one because I knew it was no longer for sale. I think it was dropped a couple of years ago.
    I'm trying to find someone who may profile these devices for me for a small fee, though this is also proving difficult...
    I have the equipment and software to do that. The only real issue creating printer profiles long distance is making sure the targets get printed correctly. Depending on the printer drivers, and sometimes the printer itself, it sometimes isn't even possible.
    or (in one very surprising case) don't profile their equipment at all
    That is very surprising. I'd sure like to know how they can get any kind of consistent and accurate color between monitor/printer/camera/scanner.
    Most places though don't waste time trying to profile digital cameras for a couple of reasons. One is that it's the rare camera (usually only on the very high end) that will take an untagged image. No profile embedded, like Adobe RGB; no defined white point color, nada. Necessary to create a profile. RAW is untagged, but then when you open such a file in Photoshop; say from a Nikon D700, you have to choose a color space to tag it with while opening the image from the RAW plug-in to the PS interface.
    The other reason is that profiles are very specific to the method used to create them. Say you profile your monitor. Then you change the brightness or contrast controls. Your profile is now useless since the monitor is no longer at the settings used to create the profile. With a digital camera, if you create an accurate profile, it's only good as long as you never move the camera, change the lens or zoom setting, or move any of the lighting. As soon as you do, you invalidate the profile.
    Here's another option. Much better than the ColorMunki to do your monitor and printer profiles. Not as inexpensive as the ColorMunki, but not empty your pockets expensive like an i1iSis/ProfileMaker 5 or Monaco Profiler bundle. X-Rite's i1Xtreme. The only drawback is that you have to choose an i1 spectrophotometer with or without a UV cut filter. It's fixed in the main unit depending on which one you buy and can't be changed. I mention this because having the UV filter is necessary to create printer profiles that will produce correct color output by cutting the UV brighteners in many papers. Colors tend to come out odd otherwise. As far as a monitor, different people at X-Rite have told me two different things. One said you should have a non UV cut unit for monitors. The other said it doesn't make any difference.
    The other drawback to the i1 Pro (XTreme) bundle is that there is still no scanner profiling in it.

  • AHHHHHH! Multiple open file chooser windows

    Ok, I am going nuts here. I have figured out the problem of getting the data to appear on the same frame that I originally open. The menu at the top has File -> Open. When the user first comes into the form, that is the only thing enabled. I am using a different file opener for this initial opening. Here is why (although, it doesn't fix the problem):
    When the user opens the file, the data appears in the frame. If the user opens another file, the data appears in the frame and another file open chooser window appears even though the users did not select it again. If the user then opens another file, then that is it. If the user then goes to the menu and selects File->Open the file open chooser appears. The user selects a file and the data appears in the frame, but another file open chooser appears. I have had it happen up to 8 times. Now, I have no idea why this is getting called over and over again. It is this that is being called multiple times:
           jMenuFileOpen.addActionListener(new ActionListener()  {
            public void actionPerformed(ActionEvent e) {
              System.out.println("IS THIS THE OPEN THAT IS CALLED OVER AND OVER AND OVER AGAIN");
              jMenuFileOpen_actionPerformed(e);
          });That println is printing each time another file open chooser window appears. I am pulling out my hair trying to figure this one out. The way I am starting this up is this:
      public FDASFrame(File file) {
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        inputfile = file;
        try {
          jbInit();
        catch(Exception e) {
          e.printStackTrace();
      public void setFile (File file) {
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        inputfile = file;
        try {
          jbInit();
        catch(Exception e) {
          e.printStackTrace();
      }These methods are in the main frame - FDASFrame. I am wondering if that is the problem. Here is the part of the filechooser that calls the main frame when the file is gotten:
                parent.setFile(file);
                JFrame frame = (JFrame)parent;Has anyone got any ideas to this problem? It might solve the problem of the tables getting duplicate data in them, too, each time a new file is opened.
    Thanks to anyone who has any ideas on how to solve this. I am stumped.
    Allyson

    I have other tests, but this is the one that is messing me up. Here is the whole file chooser (it is really long):
    package sdh;
    import java.io.*;
    //import java.io.File;
    //import java.io.FileInputStream;
    //import java.io.BufferedReader;
    //import java.io.InputStreamReader;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    //import javax.swing.filechooser.*;
    import java.util.*;
    import org.w3c.dom.Document;
    import org.w3c.dom.*;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    public class FileChooserFrame extends JFrame {
      static File file;
      String tempfile, wholeline;
      PrintWriter textfile;
      Hashtable QualityCodes = new Hashtable();
      Hashtable DistanceCodes = new Hashtable();
      Hashtable ScreeningCodes = new Hashtable();
      Hashtable ObjectCodes = new Hashtable();
      Hashtable WeatherCodes = new Hashtable();
      Hashtable StabilityCodes = new Hashtable();
        public FileChooserFrame(FDASFrame parent, String filetype) {
          //Create a file chooser
          if (filetype.equals("Open")) {
            final JFileChooser fc = new JFileChooser();
            fc.addChoosableFileFilter(new xmlExtensionFileFilterClass());
            fc.addChoosableFileFilter(new fsExtensionFileFilterClass());
            fc.addChoosableFileFilter(new sdmExtensionFileFilterClass());
            fc.addChoosableFileFilter(new rcvExtensionFileFilterClass());
            fc.addChoosableFileFilter(new txtExtensionFileFilterClass());
            fc.setAcceptAllFileFilterUsed(false);
            int returnVal = fc.showOpenDialog(FileChooserFrame.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
              file = fc.getSelectedFile();
              String ext = fc.getSelectedFile().toString().substring(fc.getSelectedFile().toString().indexOf(".")+1);
              /** @todo FDASFrame comes up each time you open a file - does not put data in the one already up */
    //        FDASFrame fdas = FDASFrame.getInstance();
    //          JFrame frame = new FDASFrame(file);
              if (ext.equals("txt")) {
                parent.setFile(file);
                JFrame frame = parent;
    //            JFrame frame = new FDASFrame(file);
                try {
                  String v;
                  FileInputStream f = new FileInputStream(file);
                  BufferedReader b = new BufferedReader(new InputStreamReader(f));
                  if ((v = b.readLine()) != null) {
                    StringTokenizer t = new StringTokenizer(v,"|");
                    if (t.nextElement().equals("FH")) {
                      frame.setTitle(t.nextElement().toString() + " Version " + t.nextElement().toString());
                catch(Exception ee) {
                  ee.printStackTrace();
                frame.addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) {
                    System.exit(0);
                frame.setVisible(true);
              else if (ext.equals("xml") || ext.equals("sdm") || ext.equals("sdm.xml")) {
                // Hashtable for WeatherCodes for setups
                WeatherCodes.put("Clear","4");
                WeatherCodes.put("Pt. Cloudy","3");
                WeatherCodes.put("Cloudy","2");
                WeatherCodes.put("Hazy/Foggy","1");
                WeatherCodes.put("","0");
                // Hashtable for StabilityCodes for setups
                StabilityCodes.put("Good","3");
                StabilityCodes.put("Fair","2");
                StabilityCodes.put("Poor","1");
                StabilityCodes.put("","0");
                // Hashtable for ObjectCodes for objects
                ObjectCodes.put("Land","9");
                ObjectCodes.put("Mountain","8");
                ObjectCodes.put("Water","7");
                ObjectCodes.put("Dense Trees","6");
                ObjectCodes.put("Thin Trees","5");
                ObjectCodes.put("Building","4");
                ObjectCodes.put("Tower","3");
                ObjectCodes.put("Pole","2");
                ObjectCodes.put("Antenna","1");
                ObjectCodes.put("","0");
                // Hashtable for ScreeningCodes for objects
                ScreeningCodes.put("High","4");
                ScreeningCodes.put("Doubtful","3");
                ScreeningCodes.put("Intermediate","2");
                ScreeningCodes.put("Photo","1");
                ScreeningCodes.put("","0");
                // Hashtable for DistanceCodes for objects
                DistanceCodes.put("Feet","3");
                DistanceCodes.put("Meters","2");
                DistanceCodes.put("NMI","1");
                DistanceCodes.put("","0");
                // Hashtable for QualityCodes for points
                QualityCodes.put("High","3");
                QualityCodes.put("Medium","2");
                QualityCodes.put("Low","1");
                QualityCodes.put("","0");
                try{
                  tempfile = fc.getCurrentDirectory().toString() + "\\Tempxml.txt";
                  textfile = new PrintWriter(new BufferedWriter(new FileWriter(tempfile)));
                catch(Exception ee) {
                  ee.printStackTrace();
                try {
                  DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
                  DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
                  Document doc = docBuilder.parse(file);
                  // normalize text representation
                  doc.getDocumentElement ().normalize ();
                  NodeList rootlist = doc.getElementsByTagName("root");
                  NodeList FHList = null;
                  Node rootnode = rootlist.item(0);
                  if(rootnode.getNodeType() == Node.ELEMENT_NODE){
                    Element FHElement = (Element)rootnode;
                    FHList = FHElement.getElementsByTagName("FileHeader");
                    Element FHeElement = (Element)FHList.item(0);
                    NodeList textFHList = FHeElement.getChildNodes();
                    wholeline = ((Node)textFHList.item(0)).getNodeValue().trim();
                  Node FHnode = FHList.item(0);
                  if(FHnode.getNodeType() == Node.ELEMENT_NODE){
                    Element FHelemElement = (Element)FHnode;
                    NodeList IDList = FHelemElement.getElementsByTagName("Identifier");
                    Element IDElement = (Element)IDList.item(0);
                    NodeList textIDList = IDElement.getChildNodes();
                    wholeline = wholeline + "|" + ((Node)textIDList.item(0)).getNodeValue().trim();
                    NodeList VerList = FHelemElement.getElementsByTagName("Version");
                    Element VerElement = (Element)VerList.item(0);
                    NodeList textVerList = VerElement.getChildNodes();
                    wholeline = wholeline + "|" + ((Node)textVerList.item(0)).getNodeValue().trim();
                    textfile.println(wholeline);
                  wholeline = "";
                  NodeList siteList = doc.getElementsByTagName("Site");
                  Element siteElement = (Element)siteList.item(0);
                  NodeList textsiteList = siteElement.getChildNodes();
                  wholeline = ((Node)textsiteList.item(0)).getNodeValue().trim();
                  Node sitenode = siteList.item(0);
                  if (sitenode.getNodeType() == Node.ELEMENT_NODE) {
                    Element siteelemElement = (Element) sitenode;
                    NodeList SiteNameList = siteelemElement.getElementsByTagName("Site_Name");
                    Element SiteNameElement = (Element)SiteNameList.item(0);
                    NodeList textSiteNameList = SiteNameElement.getChildNodes();
                    wholeline = wholeline + "|" + ((Node)textSiteNameList.item(0)).getNodeValue().trim();
                    NodeList EquipTypeList = siteelemElement.getElementsByTagName("Equipment_Type");
                    Element EquipTypeElement = (Element)EquipTypeList.item(0);
                    NodeList textEquipTypeList = EquipTypeElement.getChildNodes();
                    wholeline = wholeline + "|" + ((Node)textEquipTypeList.item(0)).getNodeValue().trim();
                    NodeList LatList = siteelemElement.getElementsByTagName("Site_Latitude");
                    Element LatElement = (Element)LatList.item(0);
                    NodeList textLatList = LatElement.getChildNodes();
                    wholeline = wholeline + "|" + ((Node)textLatList.item(0)).getNodeValue().trim();
                    NodeList LonList = siteelemElement.getElementsByTagName("Site_Longitude");
                    Element LonElement = (Element)LonList.item(0);
                    NodeList textLonList = LonElement.getChildNodes();
                    wholeline = wholeline + "|" + ((Node)textLonList.item(0)).getNodeValue().trim();
                    NodeList GtFPList = siteelemElement.getElementsByTagName("Ground_to_Focal_Point");
                    Element GtFPElement = (Element)GtFPList.item(0);
                    NodeList textGtFPList = GtFPElement.getChildNodes();
                    wholeline = wholeline + "|" + ((Node)textGtFPList.item(0)).getNodeValue().trim();
                    NodeList SiteElvList = siteelemElement.getElementsByTagName("Site_Elevation");
                    Element SiteElvElement = (Element)SiteElvList.item(0);
                    NodeList textSiteElvList = SiteElvElement.getChildNodes();
                    wholeline = wholeline + "|" + ((Node)textSiteElvList.item(0)).getNodeValue().trim();
                    NodeList UCAList = siteelemElement.getElementsByTagName("Upper_Coverage_Angle");
                    Element UCAElement = (Element)UCAList.item(0);
                    NodeList textUCAList = UCAElement.getChildNodes();
                    wholeline = wholeline + "|" + ((Node)textUCAList.item(0)).getNodeValue().trim();
                  textfile.println(wholeline);
                  NodeList listOfSetups = doc.getElementsByTagName("Setup");
                  int totalSetups = listOfSetups.getLength();
                  for (int s = 0; s < totalSetups; s++) {
                    wholeline = "";
                    Node Setupnode = listOfSetups.item(s);
                    Element setupElement = (Element)listOfSetups.item(s);
                    NodeList textsetupList = setupElement.getChildNodes();
                    wholeline = ((Node)textsetupList.item(0)).getNodeValue().trim();
                    if (Setupnode.getNodeType() == Node.ELEMENT_NODE) {
                      Element setuplistElement = (Element)Setupnode;
                      NodeList SurveyorList = setuplistElement.getElementsByTagName("Surveyor");
                      Element SurveyorElement = (Element)SurveyorList.item(0);
                      NodeList textSurveyorList = SurveyorElement.getChildNodes();
                      wholeline = wholeline + "|" + ((Node)textSurveyorList.item(0)).getNodeValue().trim();
                      NodeList Azi2FPList = setuplistElement.getElementsByTagName("Azimuth_to_Focal_Point");
                      Element Azi2FPElement = (Element)Azi2FPList.item(0);
                      NodeList textAzi2FPList = Azi2FPElement.getChildNodes();
                      wholeline = wholeline + "|" + ((Node)textAzi2FPList.item(0)).getNodeValue().trim();
                      NodeList Dist2FPList = setuplistElement.getElementsByTagName("Dist_to_Focal_Point");
                      Element Dist2FPElement = (Element)Dist2FPList.item(0);
                      NodeList textDist2FPList = Dist2FPElement.getChildNodes();
                      wholeline = wholeline + "|" + ((Node)textDist2FPList.item(0)).getNodeValue().trim();
                      NodeList Hi2FPList = setuplistElement.getElementsByTagName("Hi_to_Focal_Point");
                      Element Hi2FPElement = (Element)Hi2FPList.item(0);
                      NodeList textHi2FPList = Hi2FPElement.getChildNodes();
                      wholeline = wholeline + "|" + ((Node)textHi2FPList.item(0)).getNodeValue().trim();
                      NodeList WeatherList = setuplistElement.getElementsByTagName("Weather");
                      Element WeatherElement = (Element)WeatherList.item(0);
                      NodeList textWeatherList = WeatherElement.getChildNodes();
                      wholeline = wholeline + "|" + (String)WeatherCodes.get(((Node)textWeatherList.item(0)).getNodeValue().trim());
                      NodeList StabilityList = setuplistElement.getElementsByTagName("Stability");
                      Element StabilityElement = (Element)StabilityList.item(0);
                      NodeList textStabilityList = StabilityElement.getChildNodes();
                      wholeline = wholeline + "|" + (String)StabilityCodes.get(((Node)textStabilityList.item(0)).getNodeValue().trim());
                      Element objectElement = (Element)Setupnode;
                      NodeList textobjectList = objectElement.getElementsByTagName("Object");
                      int TotalObjs = textobjectList.getLength();
                      if (TotalObjs == 0) {
                        textfile.print(wholeline);
                      else {
                        textfile.println(wholeline);
                      for (int j = 0; j < TotalObjs; j++) {
                        wholeline = "";
                        Node Objectnode = textobjectList.item(j);
                        Element objectelement = (Element)textobjectList.item(j);
                        NodeList textObjList = objectelement.getChildNodes();
                        wholeline = ((Node)textObjList.item(0)).getNodeValue().trim();
                        if (Objectnode.getNodeType() == Node.ELEMENT_NODE) {
                          Element objElement1 = (Element)Objectnode;
                          NodeList textobjList1 = objElement1.getElementsByTagName("Object_Type");
                          Element objelement1 = (Element)textobjList1.item(0);
                          NodeList textOList1 = objelement1.getChildNodes();
                          wholeline = wholeline + "|" + (String)ObjectCodes.get(((Node)textOList1.item(0)).getNodeValue().trim());
                          Element objElement2 = (Element)Objectnode;
                          NodeList textobjList2 = objElement2.getElementsByTagName("Screening_Type");
                          Element objelement2 = (Element)textobjList2.item(0);
                          NodeList textOList2 = objelement2.getChildNodes();
                          wholeline = wholeline + "|" + (String)ScreeningCodes.get(((Node)textOList2.item(0)).getNodeValue().trim());
                          Element objElement3 = (Element)Objectnode;
                          NodeList textobjList3 = objElement3.getElementsByTagName("Distance_Units");
                          Element objelement3 = (Element)textobjList3.item(0);
                          NodeList textOList3 = objelement3.getChildNodes();
                          wholeline = wholeline + "|" + (String)DistanceCodes.get(((Node)textOList3.item(0)).getNodeValue().trim());
                          Element PointElement = (Element)Objectnode;
                          NodeList textPointList = PointElement.getElementsByTagName("Point");
                          int TotalPts = textPointList.getLength();
                          textfile.println(wholeline);
                          for (int k = 0; k < TotalPts; k++) {
                            wholeline = "";
                            Node Pointnode = textPointList.item(k);
                            Element pointelement = (Element)textPointList.item(k);
                            NodeList textPList = pointelement.getChildNodes();
                            wholeline = ((Node)textPList.item(0)).getNodeValue().trim();
                            if (Pointnode.getNodeType() == Node.ELEMENT_NODE) {
                              Element pointElement1 = (Element)Pointnode;
                              NodeList textpointList1 = pointElement1.getElementsByTagName("Azimuth");
                              Element pointelement1 = (Element)textpointList1.item(0);
                              NodeList textPList1 = pointelement1.getChildNodes();
                              wholeline = wholeline + "|" + ((Node)textPList1.item(0)).getNodeValue().trim();
                              Element pointElement2 = (Element)Pointnode;
                              NodeList textpointList2 = pointElement2.getElementsByTagName("Vertical_Angle");
                              Element pointelement2 = (Element)textpointList2.item(0);
                              NodeList textPList2 = pointelement2.getChildNodes();
                              wholeline = wholeline + "|" + ((Node)textPList2.item(0)).getNodeValue().trim();
                              Element pointElement3 = (Element)Pointnode;
                              NodeList textpointList3 = pointElement3.getElementsByTagName("Distance");
                              Element pointelement3 = (Element)textpointList3.item(0);
                              NodeList textPList3 = pointelement3.getChildNodes();
                              wholeline = wholeline + "|" + ((Node)textPList3.item(0)).getNodeValue().trim();
                              Element pointElement4 = (Element)Pointnode;
                              NodeList textpointList4 = pointElement4.getElementsByTagName("Quality");
                              Element pointelement4 = (Element)textpointList4.item(0);
                              NodeList textPList4 = pointelement4.getChildNodes();
                              wholeline = wholeline + "|" + (String)QualityCodes.get(((Node)textPList4.item(0)).getNodeValue().trim());
                            textfile.println(wholeline);
                  textfile.close();
                  File f = new File(tempfile);
    //              JFrame frame = new FDASFrame(f);
                  parent.setFile(f);
                  JFrame frame = parent;
                  if(FHnode.getNodeType() == Node.ELEMENT_NODE){
                    Element FHelemElement = (Element)FHnode;
                    NodeList IDList = FHelemElement.getElementsByTagName("Identifier");
                    Element IDElement = (Element)IDList.item(0);
                    NodeList textIDList = IDElement.getChildNodes();
                    NodeList VerList = FHelemElement.getElementsByTagName("Version");
                    Element VerElement = (Element)VerList.item(0);
                    NodeList textVerList = VerElement.getChildNodes();
                    frame.setTitle(((Node)textIDList.item(0)).getNodeValue().trim() + " Version " + ((Node)textVerList.item(0)).getNodeValue().trim());
                  frame.addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent e) {
                     System.exit(0);
                  frame.setVisible(true);
                catch(Exception ee) {
                  ee.printStackTrace();
          else if (filetype.equals("Save")) {
            final JFileChooser fc = new JFileChooser();
            fc.setFileFilter(new saveExtensionFileFilterClass());
            fc.setAcceptAllFileFilterUsed(false);
            int returnVal = fc.showSaveDialog(FileChooserFrame.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
              file = fc.getSelectedFile();
          else if (filetype.equals("Log")) {
            final JFileChooser fc = new JFileChooser();
            fc.setFileFilter(new logExtensionFileFilterClass());
            fc.setAcceptAllFileFilterUsed(false);
            int returnVal = fc.showSaveDialog(FileChooserFrame.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
              file = fc.getSelectedFile();
        public static File getFile() {
          return file;
    }I know I should split this out and I will sometime, but for now, this is the way the code is.
    I think the reason that nothing is coming up is that all my work is done in jbInit(). I don't want to post that code, but I will if needed. So, if I can only call it once, then how do I get the rest of it to run? Maybe I am going about this all wrong. But if it is not in jbInit(), then how does it get called? I guess now, I am confused.
    Thanks for the help.
    Allyson

  • Vigenere Cipher ---- Scanner/PrintWriter

    Hey All,
    I am an Java introduction course and we have been assigned a project to implement a code our professor designed, based off of his algorithms.
    I completed the code and it compiles fine, but when I fill in the 5 command lines and run it it doesn't produce the proper results.
    If the string in the 5th command line starts with an 'e', 'E', or any character besides 'd'/'D', it is supposed to take the text from the file in the 1st command line and encode it print it to the file in the 2nd command line. The problem is that it is taking whatever is in the file it is scanning and then just prints it to the other file without any change, but I do not know where I went wrong in the code. Any help is greatly appreciate, thanks!
    The code didn't copy/paste so well into here from jGRASP, I hope it's not too jarbled for you :X
    (CODE WILL BE IN 2nd POST)

                    import java.io.*; 
         import java.util.*;
        public class VigenereCodeDevice
       ************************* ALGORITHM FOR MAIN  ***********************************
       main(args)
       fileScanner <-- new Scanner(new File(args[0]))
         filePrinter <-- PrintWriter(new File(args[1]))
         key <-- args[2].toUpperCase()
         encode <-- true
         if args[4].charAt(0) is 'd' or args[4].charAt(0) is 'D'
           encode <-- flase
         rotation <-- Integer.parseInt(args[3])
         if rotation < 0
           rotation <-- rotation * -1
         rotation <-- rotation % 26
         if rotation is 0
           rotation <-- 1
         keyPosition <-- 0
         while fileScanner.hasNextLine()
           line <-- fileScanner.nextLine()
           lineBuffer <-- new StringBuffer(line)
           keyPosition <-- encodeDecode(lineBuffer, key, keyPosition, rotation, encode)
           filePrinter.println(lineBuffer)
         filePrinter.close()
          public static void main(String[] args) throws Exception
                Scanner fileScanner = new Scanner(new File(args[0]));
                PrintWriter filePrinter = new PrintWriter(new File(args[1]));
                String key = args[2].toUpperCase();
                boolean encode = true;
                if ((args[4].charAt(0) == 'd') || (args[4].charAt(0) == 'D'))
                  encode = false;
                int rotation = Integer.parseInt(args[3]);
                if (rotation < 0)
                  rotation *= -1;
                rotation %= 26;
                if (rotation == 0)
                  rotation = 1;
                int keyPosition = 0;
                while (fileScanner.hasNextLine()){
                  String line = fileScanner.nextLine();
                    StringBuffer lineBuffer = new StringBuffer(line);
                    keyPosition = encodeDecode(lineBuffer, key, keyPosition, rotation, encode);
                    filePrinter.println(lineBuffer);
                           }//while
                filePrinter.close();          
              }//main
       ************************* ALGORITHM FOR encodeDecode  ***************************
       encodeDecode(lineBuffer, key, keyPosition, rotation, encode)                    
       for textPosition <-- 0; textPosition < lineBuffer.length(); textPosition++                    
         nextChar <-- lineBuffer.charAt(testPosition)
           displacement <-- findDisplacement(key.charAt(keyPosition), rotation, encode)
           keyPosition <-- (keyPosition + 1) % key.length()
           if nextChar >= 'a' && nextChar <= 'z'
             nextChar = (char)(nextChar + displacement)
               if nextChar > 'z' nextChar <-- (char)(nextChar - 26)
           else if nextChar >= 'A' && nextChar <= 'Z'
             nextChar = (char)(nextChar + displacement)
               if nextChar > 'Z' nextChar <-- (char)(nextChar - 26)
           lineBuffer.setCharAt(textPosition, nextChar)
         return keyPosition
          private static int encodeDecode(StringBuffer lineBuffer, String key, int keyPosition, int rotation, boolean encode)
                for (int textPosition = 0; textPosition < lineBuffer.length(); textPosition++)
                  char nextChar = lineBuffer.charAt(textPosition);
                    int displacement = findDisplacement(key.charAt(keyPosition), rotation, encode);
                    keyPosition = (keyPosition + 1) % key.length();
                    if ((nextChar >= 'a') && (nextChar <= 'z'))
                      nextChar = (char)(nextChar + displacement);
                        if (nextChar > 'z')
                          nextChar = (char)(nextChar - 26);
                    }//if
                    else if ((nextChar >= 'A') && (nextChar <= 'Z'))
                      nextChar = (char)(nextChar + displacement);
                        if (nextChar > 'Z')
                          nextChar = (char)(nextChar - 26);
                    }//else if
                  }//for
                return keyPosition;
              }//encodeDecode      
       ************************* ALGORITHM FOR findDisplacement  ***********************
       findDisplacement(charDisplace, rotation, encode)
         if charDisplace < 'A' or charDisplace > 'Z'
           if encode return 1
           else return 25
         displacement <-- charDisplace - 'A'
         displacement <-- displacement + rotation
         displacement <-- displacement % 26
         if not encode
           displacement <-- 26 - displacement
         return displacement
          private static int findDisplacement(char charDisplace, int rotation, boolean encode)
                if ((charDisplace < 'A') || (charDisplace > 'Z'))
                  if (encode)
                      return 1;
                              else
                      return 25;
                }//if
                int displacement = charDisplace - 'A';
                displacement += rotation;
                displacement %= 26;
                if (!encode)
                  displacement = 26 - displacement;
                return displacement;
              }//findDisplacement
        }//class

Maybe you are looking for

  • .PLEASE REPLY. is the ios6 out? btw Siri is it only ipad 3? or also ipad 2. cus i only have ipad 2. PLEASE SAY IT WORKS ON ipad 2!!!!!!!

    PLEASE REPLY. is the ios6 out? btw Siri is it only ipad 3? or also ipad 2. cus i only have ipad 2. PLEASE SAY IT WORKS ON ipad 2!!!!!!!

  • Ipad has been disabled

    Hi all, My ipad has been disabled due to incorrect password keyed. I know I can recover it by connecting it to the old pc that was used to sync with this ipad.Yet, my real problem is that that old PC has was not working any more...pls help...:(

  • Clicking on any row in a record set

    How can I click any where in a row and retrieve that records data in a report. I know how to highlight a row. Any help would be appreciated. Thanks Aron

  • Gather table stats

    Hi All, DB version:10.2.0.4 OS:Aix 6.1 I want to gather table stats for a table since the query which uses this table is running slow. Also I noticed that this table is using full table scan and it was last analyzed 2 months back. I am planning to ex

  • DDL for any table

    Hallo,, all i want to set DDL for 2 table and other table not have DDL, How to use DDL parameter in extract group..? Thanks, Riyas