File sometimes saves as unicode, sometimes as ANSI problem

Hi all,
I'm having an issue whereby a .vi I've created to save string data sometimes saves the .txt file as ANSI and sometimes as Unicode. Unfortunately the unicode appears to be Chinese characters when opened in notepad. When I open the same file in notepad++ the data is there but in unicode format. I'd like to try and understand why this is happening and fix it. Any advice would be appreciated. I've included the .vi, ansi output example and a unicode output example.
Brief description of the vi functionality:
The .vi simply saves the input string to the filename (and path) supplied in Log File Path. It checks conditions for file existing, path exisiting and creates any missing pieces (folders, files). Then it opens the file for writing, sets 'append' and writes to the files. Lastly it closes the file.
I can not figure out what is causing it to sometimes save as unicode and sometimes as ansi. Please let me know if there is anything further I can provide.
Cheers,
Alex
Alexander H. | Software Developer | CLAD
Attachments:
Unicode.txt ‏274 KB
Log.vi ‏16 KB
Unicode.txt ‏274 KB

alexhunt wrote:
Hi all,
I can not figure out what is causing it to sometimes save as Unicode and sometimes as ANSI. Please let me know if there is anything further I can provide.
Hi, alex,
The file seems to be saved correctly and its not saved as Unicode. The file opened as Unicode.
Do simple experiment:
1. Start Notepad:
2. Type 'AAAA BBB CCC DDDDD':
3. Save it. As you can see in hex viewer, my file is correct:
4. Now open this file in notepad, you will be surprised:
This is true for XP, not sure how it works with Windows 7.
Try to open your file in that way:
Andrey.

Similar Messages

  • Cant download or save file sometimes

    When i try to download a file or save it, it starts to download normally till it finished and this pops up "www.xxxx.com could not be saved, because you cannot change the contents of that folder.
    Change the folder properties and try again, or try saving in a different location."
    It always happen. I tried saving it into different places like on my desktop and in other drives but the same thing pops up. I really have no idea and this is interfering with work so please please i really need help.
    Thankyou
    == This happened ==
    Every time Firefox opened
    == It started 2 days ago

    This may be a problem with the %TEMP% folder.
    Firefox immediately starts downloading the file to the temp folder and move the file after you have supplied the name and location to that folder.
    It is possible that your anti-virus software is corrupting the downloaded files or otherwise interfering with downloading files by Firefox.
    You can try to disable the real-time (live) scanning of files in your anti-virus software temporarily to see if that makes downloading work.
    Do not forget to re-enable the scanning in your anti-virus software after you are finished with downloading and installing.
    See [[Unable to download or save files]]
    See also http://kb.mozillazine.org/Unable_to_save_or_download_files (Disable virus scanning in Firefox preferences - Windows)
    (the MozillaZine KB is currently down, so you may need to try again later)

  • Indesign CS4 in Mac 10.6.8, sometimes won't show files, sometimes won't show tools

    Indesign CS4 in Mac 10.6.8, sometimes won't show files, sometimes won't show tools. Like I click to open a file from the finder, and Indesign makes that temporary file in the finder, but won't display the pages. At other times I can have the pages displayed but I can't open the tools such as the colour swatches or the paragraphy styles. This all happens at random, although I suspect it is more likely to happen if I have been working in some other program such as Typestyler or Aperture, and come back to Indesign. Kind of like Indesign gets snooty at me working in another program.
    I've done the thing of dicing the preferences, but so far the only workaround that has worked so far is quitting and restarting the program. I don't remember this happening so much until recently, in other words the problem seems to be getting more frequent.
    But I am wondering if this has happened with anyone else and if there are any other suggestions for avoiding it.
    Back in the good old days you would reinstall PageMaker and that would settle things for a while. But now I don't know if a program like Indesign CS4 actually gets corrupted and if it does I don't know what to do. Does the program get corrupted? And should you reinstall a fresh copy? If it's a good idea to reinstall the program how do you do that? Is it possible to download a fresh copy? And if I do, what happens when the fresh copy phones home? I've tangled with the Adobe Microsoft corporation before when Indesign phoned home and got a crossed line.

    Other things to try:
    Examine your specific version of Optima by going to Type menu > Find Font, clicking on the Optima font and choosing More Info (I think) and find the specific version number. See if you can uninstall the font and reinstall another Optima font with a different, preferably newer version number. There has (historically) been a bad version of Optima floating around for years. Maybe you have it.
    Use a free utility like FontNuke or FontFinagler to get your Mac OS to reset its font plists. Sometimes that makes the OS feel better.
    Use the built-in Disk Utility to repair file permissions. You never know.
    Export your old document out to IDML and reopen that resulting idml file back into a new freshly written INDD file. This might remove internal database corruptions.
    All these are chicken-soup things to try and they might be good for you.
    Best,
    Mike Witherell in Florida

  • When placing a Illustrator file in Indesign, the Illustrator file sometime changes from 100%.

    When placing a Illustrator file in Indesign, the Illustrator file sometime changes from 100%. When you select the placed file with the selection tool, it says 100%, but if you select with the direction tool, file has been changed any where from 98 to 102 %, not staying at the 100%? why is this and how can you asure the size does not change when placed or when updating the illustrator link?

    Probably you have inserted files in a frame whose content was previously adequate with "Fit Content Proportionally" or "Fill Frame Proportionally".
    The new content in the same frame will have the same characteristics as the previous one

  • How export to csv work in safari browser? In my application export to csv open like a raw data in new tab. But other browsers working great!. Need to open in a csv file or save it as a csv file.

    How export to csv work in safari browser?
    In my application export to csv open like a raw data in new tab.
    But other browsers working great!.
    Need to open in a csv file or save it as a csv file.
    Please suggest me. Thank you in advance!.

    Hi Adrian,
    Why don't you try any another software for opening CSV files then Notepad ? According to my experience, you can use these softwares to open an CSV files and they are:-
    Microsoft Excel
    Open Office Calc
    Google Docs
    Also there is an additional tool available known as CSV viewer. You may try this, download it from here http://www.csvviewer.com/
    I've never used Notepad for opening CSV files, because sometimes it contains some symbols which are not not at all compatibile with Notepad.
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • List of downloads is blank after I changed the file to save to. How can I restore the list of downloads?

    I have already tried the all the steps in this link.
    '''http://support.mozilla.com/en-US/kb/Downloads%20window%20is%20blank?s=+downloads+list&as=s'''
    I have changed the file to save to back to the original one as well.

    Try opening the problem files using a text editor or file viewer to see what the first few bytes contain. All valid FM binary files for FM 11 will contain <MakerFile 11.0> in the first bytes of the file.
    When updating books, it's sometimes better to just to create a new book file and add the files to that.
    When renaming files in a book, changes at the system level will break any links/cross-references between files, so it's always best to use the Rename option in the Book file to change FM file names. This will maintain the correct linkages.

  • Editing CSS, related files requires save (cs4)

    You know what really Grinds My Gears? (family guy reference,
    lol)
    When I edit the CSS in the right hand panel, sometimes it
    makes the CSS file in the Related Files toolbar not saved with a *
    next to the filename. Sometimes it goes ahead and just saves the
    changes right away. Like most, I'm constantly switching back/forth
    between browsers so CSS has to be saved to see changes.
    Kindofa pain to have to click the css file in the related
    toolbar and Ctrl+S to save before each preview...I haven't been
    able to find out why it "dirties" the CSS file sometimes and other
    times it directly saves to the CSS file.
    Does anyone have any ideas? How to get it to always just save
    to the file?
    thanks

    avibodha,
    Ah! Thanks for the additional details. I see what is causing
    this behavior.
    When a document is opened, DW determines what the Related
    Files are, so
    it can show the list of buttons for each one. But, for the
    sake of
    performance, we do not actually load the files until you
    click on a
    button to view a file. Note that the file may already be
    loaded as a
    top-level document or as a Related File of some other
    document.
    Since you have the "Open CSS files when modified" setting
    turned off,
    then the CSS gets automatically saved to disk *if* the file
    has not yet
    been loaded. Once the file has been loaded, then DW will not
    automatically save it (to avoid writing something on disk
    that you don't
    want written).
    So, you'll need to disable the Related Files feature to have
    DW always
    automatically save the CSS to disk.
    HTH,
    Randy
    > * related files always on, open document
    > * edit CSS in right panel (separate css file, not inline
    styles), always saves
    > immediately
    > * Either click .css file and edit, or in right panel,
    click Go To Code and
    > edit CSS -> now all edits in right panel will happen
    to file and NOT be saved.
    > You must go to the .css file and Save it.
    >
    > So once you edit the CSS file for for any reason, from
    then on it edits the
    > css file when you use the right panel and you must go
    back to the file and
    > save, or do Save All.
    >
    > There is a setting in Preferences, CSS Styles to
    automatically open the CSS
    > file when editing, but I have that off (default state).
    >
    > Curious...wonder if there's a way to "reset" the right
    panel CSS back to it's
    > original state of directly modifying the css file? If I
    close and re-open the
    > document, that does it, but that's not a solution...
    >
    > Not a big deal because I can turn off Related Files...

  • File name save procedure

    Maybe a dumb question, but here goes. I sometimes have a problem when navigating through folders in the Save window. When my coordination or vision is less than optimal, I sometimes accidentally click on another file name which then changes the name of the file I am saving. I then must start the save process all over again or move back up to the text field to type in the correct name again. Annoying to say the least. Is there any way to change this behavior?
    Thanks,
    John
    OSX 10.3.9

    Hi John,
    you are welcome. You might want to tell Apple how much you dislike this feature by giving them feedback:
    http://www.apple.com/macosx/feedback/
    Also, please remember to mark this post as answered as this will help other people with the same question.
    Happy computing,
    -Petra

  • How do i use an input file with Asian characters(Unicode)?

    /* Ardor
    * Illiteraminator.java
    * Version beta 1.0
    * December 7, 2007
    * Main interfacing class
    import java.io.*;
    import java.util.*;
    public class Illiteraminator{
      public static void main (String [] args){
      //  ArrayList<Word> dictionary = new ArrayList<Word>();
        String fileName = "Mandrin.txt";
        String character= "",definition = "",inputLine;
        try{
          Scanner fileScan = new Scanner (new File (fileName));
          while (fileScan.hasNext()){
            inputLine = fileScan.nextLine();
            Scanner sc = new Scanner(inputLine);
            character = sc.next();
            while (sc.hasNext()){
              definition = definition + " " + sc.next();
            }//end while sc
           // dictionary.add(new Word(character, definition));
            //definition = "";
            //character = "";
          }//end while fileScan
        } catch (FileNotFoundException e){
          System.out.println("File not found, dig around for Mandrin.txt");
          System.exit(1);
        }//end catch
        System.out.println(character);
        System.out.println(definition);
      }//end main
    }//end class IlliteraminatorHi, i'm a first time programmer. Never touched programming until i took a Java class in university last semester. I am currently attempting to write a program to help me move away from my illiteracy in Mandrin. So, that's my code, and i am using Dr.Java while writing it. When i tested it out the output looked something like this v
    A p p l e
    M o n k e y C a t D o n k e y
    My input file is saved in Unicode. It contains letters that cannot be saved in ANSI. I tried UTF-8, but the interactions section showed no output...
    Is this just a problem with Dr.Java? Will i encounter a similar problem when i turn this into a GUI?
    The following is a copy and pasted version of the txt file i used as input. It is saved in the Unicode format.
    &#30340;[de] <grammatical particle marking genitive as well as simple and composed adjectives>; &#25105;* w&#466;de my; &#39640;* g&#257;ode high, tall; &#26159;* sh�de that's it, that's right; &#26159;...* sh�...de one who...; &#20182;&#26159;&#35828;&#27721;&#35821;*. T&#257; sh� shu&#333; H�ny&#468;de. He is one who speaks Chinese. [d�] &#30446;* m�d� goal [d�] true, real; *&#30830; d�qu� certainly
    &#19968;(A&#22777;)     [y&#299;] one, a little; &#31532;* d�-y&#299; first, primary; &#30475;*&#30475; k�ny&#299;k�n have a (quick) look at [y�] (used before tone #4); *&#20010;&#20154; y� g� r�n one person; *&#23450; y�d�ng certain; *&#26679; y�y�ng same; *&#26376;y�yu� January [y�] (used before tones #2 and #3); *&#28857;&#20799; y�di&#462;nr a little; *&#20123; y�xi&#275; some {Compare with &#24186;(F&#20040;) y&#257;o, which also means "one"}
    &#26159;     [sh�] to be, *&#19981;*? sh�bush�? is (it) or is (it) not?; *&#21542; sh�f&#466;u whether or not, is (it) or is (it) not?

    Sorry, but i do not understand this post at all... Can anyone explain it to me? Is he saying my IDE is running on something other than Unicode?
    PS: I tried one of the Scanner constructors that takes a charset parameter. That fixed the odd output! However, every Chinese character has been replaced with a question mark. (It was a series of weird characters before i used the constructor with a charset parameter.)

  • HT1871 Hello i have one IPhone 4S and I use 3G net in my mobile sometime I have problem with temperature in my phone at the SIM card or battery how can I fix this problem. By update or version of 6.1.3

    Hello i have one IPhone 4S and I use 3G net in my mobile sometime I have problem with temperature in my phone at the SIM card or battery how can I fix this problem. By update or version of 6.1.3

    Could it be because the SIM card got damaged while I cut it to fit the IPhone?
    Very likely. Hard to believe the carrier in Mexico doesn't have a micro-SIM card available.
    Or somehow the Chinese carrier found out and locked it?
    No, which is not possible.
    What can I do? Get a new SIM and see if it works again?
    Get a micro-SIM from the carrier in Mexico that you don't have to manually cut down. If that carrier doesn't provide one, switch to another carrier that is not so low-budget.

  • TS1702 i've an iphone 3.1.3. sometimes, i have problems opening all the apps i downloaded in the past 4 months. other apps would open but the recent ones will begin to boot and then close itself. once, it persisted for over a week. pls help as am frustrat

    i've an iphone 3.1.3. sometimes, i have problems opening all the apps i downloaded in the past 4 months. other apps would open but the recent ones will begin to boot and then close itself. once, it persisted for over a week. it staarted again this evening, pls help as am frustrated. NB- i checked for apps update but all my apps are up-to-date. CT

    Try the usual steps: restart, reset, restore.
    http://support.apple.com/kb/HT1430
    http://support.apple.com/kb/HT1414
    If restoring using a backup doesn't help, try restoring the iPhone to factory settings and try for a while with just the Apple-included apps, to make sure it's not an issue with a third-party app. If it still has problems, it may have a hardware problem and will need to be sent to Apple.
    Regards.

  • SINCE INSTALLING I.E. 11 IN WINDOWS 7, UNABLE TO DOWNLOAD OR SAVE FILES IN FIREFOX; HOW DO I CORRECT THIS PROBLEM?

    This is what I wrote to the Microsoft Community seeking a correction of the issue (still no reply to my request for assistance with this matter from them):
    Can I go back to I.E. 10? Ever since I installed version 11, I've had an unstable desktop. It appears to have damaged the Windows Explorer interface in other browsers, such that when I open the popup window to save downloads and/or other files, all that shows up in the window are the "Save" and "Cancel" buttons, but it does not show the interface to choose where to save the file(s), thus I cannot save anything at all in those other browsers. I primarily use Firefox, and every time I want to save a file, I have to startup I.E. 11 to save anything and everything.
    I would much prefer going back to I.E. 10 which caused me no such problems; but, if I cannot go back to I.E. 10, how do I correct this issue so I can save files in other browsers? This situation has been going on for months now, and I've waited patiently thinking that there would be an update for Microsoft and/or Firefox (as well as Chrome and Safari) that would correct this problem by now; but, even though I have all of the latest updates and versions installed, no updates have corrected the issue at all. I would very much appreciate any help you can give.
    Oh, also, I have tried uninstalling Firefox completely at least twice, and rebooting before reinstalling it to the latest version, but that has not corrected the problem either. I additionally tried turning I.E. 11 off in Windows, and then tried running Firefox to see if the download interface would be restored, but it still had the very same issue(s) [no ability to choose the place to save files, and thus being completely unable to save any downloads and/or other files]. I can't believe that this problem has been going on for so long now without any update(s) resolution.

    The following is the latest that I've written to Microsoft about this entire matter:
    You're still not getting it. I've never had a problem with downloading and/or saving files in I.E.; and I very clearly explained to you guys that the problem is in the other browsers, but it's caused by a malfunction in the Windows Desktop.
    Why can't someone with English as their first language, please help me?
    But, regardless, just in case your recommendation(s) had anything to do with anything, and were perhaps creating the problem in the other browser (though I was pretty sure that it had nothing to do with my problem), I made I.E. the default browser; yet, of course, that did NOT correct the problem. Also, when I set I.E. as the default browser, the explorer.exe file crashed and restarted.
    Nevertheless, because I (wrongly) thought that I couldn't uninstall I.E. 11, because somehow I missed the listing for it in Windows Programs and Features, I went to the latter again and found I.E. 11 listed this time, and uninstalled it. After it completed, I rebooted the laptop. Then I went into Windows Update and looked for what version of I.E. it was then going to want me to update to since I.E. 11 was uninstalled.
    I saw that I.E. was taken all the way back to I.E. 8 and had updates for it as well as to update to I.E. 9, so I did the former updates first, rebooted, then updated to I.E. 9 and rebooted again. Then I ran Windows Update again checking for new updates, and found that there was a cumulative security update for I.E. 9, which I installed and then rebooted once again.
    Then, upon checking for new updates in Windows Update again, I found that the option(s) to update to I.E. 10 or 11 were now optional, which they weren't before, and then I updated to I.E. 10 and rebooted once more. Upon Windows restarting, I checked again for new Windows Updates and there were some security updates, so I installed them and restarted the laptop.
    This time upon rebooting, I checked Windows Update for further new updates and there were none; so I'm now completely updated to I.E. 10; but, because going back to I.E. 10 corrected some of the instability with the Windows Desktop, I am ignoring the optional update to I.E. 11, and I am NOT going to update to it again.
    Throughout the update process, upon restarting Windows, I kept starting Firefox to see if the "Save As" window then worked, but throughout the entire update process, as well as when I completed it, I still could not download or save files [because the window still doesn't show where to save the file(s)---please see the Print Screen copy of what it looks like, attached to this message (sorry, but I.E. won't let me browse for the file, and the tab or windows crashes and reloads every time when I click "Browse" to look for the file to attach)].
    So, I decided to try uninstalling Firefox for the fourth time, rebooting and reinstalling it, hoping that might correct he issue this time since I downgraded to I.E. 10, but the "Save As" window still looks the same, and I am still completely unable to save any files or downloads while in Firefox.
    Oh, I also tried resetting all of the Windows Folder Options again to default settings, and reset all of the folders, in case that had anything to do with the problem, but that still did NOT correct the issue either.
    I am now going to try creating a new user account also with Administrator privileges, changing Users, trying to run Firefox in it, and see if the problem with the "Save As" window is still an issue....
    In the new User profile, the situation is even worse. When I try to save any file(s) in Firefox, Firefox crashes (latest version).
    I wrote to Firefox a couple of days ago, but an arrogant "techie" is giving me the run around and is not helping me, and no else is helping with the matter so far.
    Postscript: Now Windows Explorer (the explorer.exe file) that runs the desktop crashed and restarted again twice while I was trying to print a file, and it appears that it won't let me print at all anymore.

  • Read multiple files and save all into one output file(AGAIN)

    Hi, guys
    I need your help for reading data from multiple files and save the results into one output file. When files are selected from file chooser, my program read the data line by line , do some calculations and save the result into the output. I made an array to store input files and it seems to be working fine, but when it comes to SaveFile() function, issues NullPointException message.
    public class FileReduction1 extends JFrame implements ActionListener
       // GUI definition and layout
        /* ACTION PERFORMED */
        public void actionPerformed(ActionEvent event) {
            if (event.getActionCommand().equals("Open File")) getFileName();
        /* OPEN THE FILE */
        private void getFileName() {
            // Display file dialog so user can select file to open
         JFileChooser fileChooser = new JFileChooser();
         fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            fileChooser.setMultiSelectionEnabled(true);
         int result = fileChooser.showOpenDialog(this);
         // If cancel button selected return
         if (result == JFileChooser.CANCEL_OPTION) return;
            if (result == JFileChooser.APPROVE_OPTION)
             files = fileChooser.getSelectedFiles();
                textArea.setText("");
                if(files.length>0)
                    filelist="";
                    System.out.println("files length"+files.length);
                    for(int i=0;i<files.length;i++)
                         System.out.println(files.getName());
    filelist+=files[i].getName()+" ,";
    if (checkFileName(files[i]) )
    openButton.setEnabled(true);
    readButton.setEnabled(true);
    textArea.append("file "+files[i].getName()+"is a proper file"+"\n");
    readFile(files[i]);
    textfield.setText(filelist);
    else{JOptionPane.showMessageDialog(this,"Please select file(s)",
                    "Error 5: ",JOptionPane.ERROR_MESSAGE); }
         // Obtain selected file
    /* READ FILE */
    private void readFile(File fileName_in) {
    // Disable read button
    readButton.setEnabled(false);
    // Dimension data structure
         getNumberOfLines(fileName_in);
         data = new String[numLines][4];
         // Read file
         readTheFile(fileName_in);
         // Rnable open button
         openButton.setEnabled(true);
    /* GET NUMBER OF LINES */
    /* Get number of lines in file and prepare data structure. */
    private void getNumberOfLines(File fileName_in) {
    int counter = 0;
         // Open the file
         openFile(fileName_in);
         // Loop through file incrementing counter
         try {
         String line = fileInput.readLine();
         while (line != null) {
         counter++;
              System.out.println("(" + counter + ") " + line);
    line = fileInput.readLine();
         numLines = counter;
    closeFile(fileName_in);
         catch(IOException ioException) {
         JOptionPane.showMessageDialog(this,"Error reading File",
                   "Error 5: ",JOptionPane.ERROR_MESSAGE);
         closeFile(fileName_in);
         System.exit(1);
    /* READ FILE */
    private void readTheFile(File fileName_in)
    // Open the file
    //int row=0;
    int col=0;
    openFile(fileName_in);
    System.out.println("Read the file");
    // Loop through file incrementing counter
    try
    String line = fileInput.readLine();
    while (line != null)
    boolean containsDoubles = false;
    double temp;
    String[] lineParts = line.split("\t");
    try
    for (col=0;col<lineParts.length;col++)
    temp=Double.parseDouble(lineParts[col]);
    data[row][col] = lineParts[col];
    containsDoubles = true;
    System.out.print("data["+row+"]["+col+"]="+lineParts[col]+" ");
    } catch (Exception e) {row=0; col=0; temp=0.0;}
    if (containsDoubles){ row++;}
    System.out.println();
    line = fileInput.readLine();
    catch(IOException ioException)
    JOptionPane.showMessageDialog(this,"Error reading File", "Error 5: ",JOptionPane.ERROR_MESSAGE);
    closeFile(fileName_in);
    System.exit(1);
    //System.out.println("length"+data.length);
    closeFile(fileName_in);
    process(fileName_in);
    /* CHECK FILE NAME */
    /* Return flase if selected file is a directory, access is denied or is
    not a file name. */
    private boolean checkFileName(File fileName_in) {
         if (fileName_in.exists()) {
         if (fileName_in.canRead()) {
              if (fileName_in.isFile()) return(true);
              else JOptionPane.showMessageDialog(null,
                        "ERROR 3: File is a directory");
         else JOptionPane.showMessageDialog(null,
                        "ERROR 2: Access denied");
         else JOptionPane.showMessageDialog(null,
                        "ERROR 1: No such file!");
         // Return
         return(false);
    /* OPEN FILE */
    private void openFile(File fileName_in) {
         try {
         // Open file
         FileReader file = new FileReader(fileName_in);
         fileInput = new BufferedReader(file);
         catch(IOException ioException) {
         JOptionPane.showMessageDialog(this,"Error Opening File",
                   "Error 4: ",JOptionPane.ERROR_MESSAGE);
         textArea.append("OPEN FILE\n---------\n");
         textArea.append(fileName_in.getPath());
         textArea.append("\n");
         //System.out.println("File opened successfully");
    /* CLOSE FILE */
    private void closeFile(File fileName_in) {
    if (fileInput != null) {
         try {
              fileInput.close();
         catch (IOException ioException) {
         JOptionPane.showMessageDialog(this,"Error Opening File",
                   "Error 4: ",JOptionPane.ERROR_MESSAGE);
    System.out.println("File closed");
    private void process(File fileName_in) {
    //getNumberOfLines();
         //data = new String[numLines][3];
         // Read file
    double temp,temp1;
         //readTheFile();
    //System.out.println("row:"+row);
    //int number=data.length;
    //System.out.println(number);
    for (int i=0; i<row; i++)
    temp=Double.parseDouble(data[i][1]);
    sumx+=temp;
    temp1=Double.parseDouble(data[i][3]);
    sumy+=temp1;
    multixy+=(temp*temp1);
    square_x_sum+=(temp*temp);
    square_y_sum+=(temp1*temp1);
    //System.out.println("Sum(x)="+sumx);
    double tempup=(row*multixy)-(sumx*sumy);
    double tempdown=(row*square_x_sum)-(sumx*sumx);
    slope=tempup/tempdown;
    double tempbup=sumy-(slope*sumx);
    intb=tempbup/row;
    double tempside=(row*square_y_sum)-(sumy*sumy);
    double cordown=Math.sqrt(tempdown*tempside);
    corr=tempup/cordown;
    r_sqrt=corr*corr;
         textArea.append("Data for file"+ fileName_in.getName()+" have been processed successfully.");
         textArea.append("\n");
         textArea.append("Please enter output file name including extension.");
    System.out.println("number"+row);
    System.out.println("slope(m)="+slope);
    System.out.println("intecept b="+intb);
    System.out.println("correlation="+corr);
    System.out.println("correlation="+r_sqrt);
    saveFile();
    private void saveFile()
    textArea.append("SAVE FILE\n---------\n");
    if (openFile1())
         try {
              outputToFile();
    catch (IOException ioException) {
              JOptionPane.showMessageDialog(this,"Error Writing to File",
                   "Error",JOptionPane.ERROR_MESSAGE);
    private boolean openFile1 ()
         // search for the file path
    StringBuffer stringpath;
    title=textfield1.getText().trim();
    int temp=fileName_in.getName().length();
    int temp_path=fileName_in.getPath().length();
    int startd=(temp_path-temp);
    stringpath=new StringBuffer(fileName_in.getPath());
    stringpath.delete(startd, temp_path+1);
    //System.out.println("file-path="+temp_path);
    //System.out.println("length-file="+temp);
    path=stringpath.toString();
    fileName_out = new File(path, title);
    //System.out.println(file_out.getName());
    if (fileName_out==null || fileName_out.getName().equals(""))
         JOptionPane.showMessageDialog(this,"Invalid File name",
                   "Invalid File name",JOptionPane.ERROR_MESSAGE);
         return(false);
         else
    try
    boolean created = fileName_out.createNewFile();
    if(created)
    fileOutput = new PrintWriter(new FileWriter(fileName_out));
    fileOutput.println("File Name"+"\t"+"Slope(m)"+"\t"+"y-intercept(b)"+"\t"+"Coefficient(r)"+"\t"+"Correlation(R-Squared)");
    return(true);
    else
    fileOutput = new PrintWriter(new FileWriter(fileName_out,true));
    return(true);
    catch (IOException exc)
    JOptionPane.showMessageDialog(this,"Please enter the file name","Error",JOptionPane.ERROR_MESSAGE);
    return(false);
    private void outputToFile() throws IOException
    // Initial output
         textArea.append("File name = " + fileName_out + "\n");
         // Test if data exists
         if (data != null)
         fileOutput.println(fileName_in.getName() +"\t"+ slope+"\t"+intb+"\t"+corr+"\t"+r_sqrt);
    textArea.append("File output complete\n\n");
         else
    textArea.append("No data\n\n");
         // End by closing file
    initialcomp();
         fileOutput.close();
    private void initialcomp()
    slope=0.0;
    intb=0.0;
    corr=0.0;
    r_sqrt=0.0;
    sumx=0.0; sumy=0.0; multixy=0.0; square_x_sum=0.0; square_y_sum=0.0;
    for(int i=0;i<data.length;i++)
    for(int j=0;j<data[i].length;j++)
    data[i][j]=null;
    /* MAIN METHOD */
    public static void main(String[] args) throws IOException
         // Create instance of class FileChooser
         FileReduction1 newFile = new FileReduction1("File Reduction Program");
         // Make window vissible
         newFile.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         newFile.setSize(500,400);
    newFile.setVisible(true);
    Sorry about the long lines.
    As you can see, all input files saved in array called files, however when OpenFile1() function is called, it take input (fileName_in) as a single file not an array. I'm assuming this causes the exception.
    When there's muptiple inputs, program should take each file from getFileName() to outputToFile() sequentially.
    Does anybody have an idea to solve this?
    Thanks a lot!!

    you naming convention is confussing. you should follows Java naming convention..you have a getXXX but decalred the return type as "void"...get usully means to return something...
    your code is doing too much..and hard to follows..
    1. get the selected files
    for each selected file
    process the file and return the result
    write out the result.
    /** close the precious resource */
    public void closeResource(Reader in){
        if (in != null){
            try{ in.close(); }
            catch (Exception e){}
    /** get the total number of line in a file */
    public int getLineCount(File file) throws IOException{
        BufferedReader in = null;
        int lineCount = 0;
        try{
            in = new BufferedReader(new FileReader(file));
            while ((in.readLine() != null)
                lineCount++;
            return lineCount;
        finally{ closeResource (in);  }
    /** read the file */
    public void processFile(File inFile, File outFile) throws IOException{
        BufferedReader in = null;
        StringBuffer result = new StringBuffer();
        try{
            in = new BufferedReader(new FileReader(inFile));
            String line = null;
            while ((in.readLine() != null){
                .. do something with the line
                result.append(....);
            writeToFile(outFile, result.toString());
        finally{ closeResource (in);  }
    public void writeToFile(File outFile, String result) throws IOException{
        PrintWriter out = null;
        try{
            out = new PrintWriter(new FileWriter(outFile, true));  // true for appending to the end of the file
            out.println(result);
        finally{  if (out != null){ try{ out.close(); } catch (Exception e){} }  }
    }

  • How do I get a "Details" display--as the default--when downloading a file, in the "Enter name of file to save to..." dialog box?

    When I receive an attachment to an email, and I click it and select "Download", I get the "Enter name of file to save to..." dialog box (because I already set the option to "Always ask me where to save files." But the file display always defaults to a "List". At least recently. I don't recall it always doing that. In any case, I want it to default to a "Details" display, in ascending order, as I can then find things sooo much faster that way. (I often use the "Date Modified" tab to bring to the top the most recent version of a file.) I know that I can go to the "View Menu" icon and select "Details", but each time I go into a sub folder while in this dialog box, I have to do that all over again and it wastes a lot of time and attention.
    I did some internet searches but didn't find a way to fix this.

    Thanks for reaching out, glennr.
    The dialog box you are describing is controlled by Windows, not Firefox, so unfortunately Firefox cannot change what you see by default.
    I think your best bet would be to ask on the [http://answers.microsoft.com/en-us/windows/forum/windows_xp?auth=1 Windows support site].

  • When saving a PDF file, it saves multiple of the exact same documents, why/or how do I change those settings?

    When savind a PDF file, it saves multiple of the same document, why?  Are there settings to adjust or what am I doing wrong?

    This might help - I'm not sure:
    Go to System Preferences (under the Apple logo in the menu bar).  Click "General" and check "Always close windows when quitting an application."

Maybe you are looking for

  • GT70 0ND Windows 8 Downgrade

    Hello, I'm looking at how to downgrade my OS from windows 8 (pre-packaged from PCCASEGEAR) to windows 7, I have re-initialized my 2x 64gb SSD's RAID 0 setup when I go to install windows it complains that the BIOS doesn't allow booting from the drive.

  • Mail doesn't open any windows

    When I go into imail - I can see and read the contents in my inbox/outbox, but cannot open any of the messages. Likewise I cannot open a window to write a new mail. Infact I can't open any window at all, including the Mail / About Mail pop up window.

  • Mode reset failure on AIR-AP1220B

    In trying to reset a serie of 10 AP's for re-use I have the problem that "mode button reset" does not work, in other words it does not clear any passwords. This makes logging either over console or IP gui impossible. Is there any known way to resolve

  • Problems enabling perfdump

    We tried enabling perfdump, following the instructions in the iPlanet Web Server 4.1 Performance Tuning Guide, but it didn't work. We modified obj.conf and added a new object with ppath=<document root>/.perf, and Service="service-dump" inside. We the

  • New computer, can't see downloaded songs in iTunes

    I have a new computer, IBM thinkpad and when I hooked up my ipod to the newly downloaded ITunes it recognized my ipod (name and all!) but I can't see my songs in the itunes window. I have hit "sync" it shows updating, but my songs still don't appear