Write double to a file

I want to write doubles to a file without converting them to string....... how is this done?

The text file showed me squares so I could not see the hexadecimal numbers.. Then I used the bin file and I could see hexadecimal numbers.
Since I want to sort the numbers... I am wondering how I would specifically get that double number again using the input stream..
I did this:
          /*Create file or overwrite if it does exists*/
          FileInputStream fis = new FileInputStream("File1.bin");
          DataInputStream dis = new DataInputStream(fis);
          int size = fis.available();
          System.out.println("Size of File1 "+size);
          /*Get random number*/
          /*Create an array that can store 100,000 numbers*/
          double num1[] = new double[100001];
          //Write to file
          for (int count = 0; count <= size; count ++)
               num1[count] = dis.readDouble(num1[count]); ------This line problem
               System.out.println(num1[count]);
In the API - double readDouble() is method under DataInputStream but when I compile this...
This is the error I get:
SingleThread.java:28: readDouble() in java.io.DataInputStream cannot be applied
to (double)
num1[count] = dis.readDouble(num1[count]);

Similar Messages

  • How to write '\n' in text file instead of newline

    Hello Everyone,
    I am trying to write 'C:\DOCUME~1\nXXX\LOCALS~1\Temp' in a bat file using client_text_io but *'\n'* in the path is taken as a new line character and the path is broken into two lines and written to the file. Hence my bat file doesnt work. I would need to write '\n' in the file as there are many reports which has '\n' in the output. Please provide a solution for writing '\n' in the file without getting it converted to a new line.
    DECLARE
         out_file client_text_io.file_type;
    BEGIN
    :GLOBAL.TEMPDRIVE :=client_win_api_environment.get_environment_string('TEMP'); --output is 'C:\DOCUME~1\nXXX\LOCALS~1\Temp'
    out_file := client_Text_IO.fopen(:GLOBAL.TEMPDRIVE||'\chkdirz.bat', 'w');
    client_Text_IO.PutF(out_file,'chdir '||:GLOBAL.TEMPDRIVE||'\ \n');
    client_Text_IO.PutF(out_file,'if EXIST '||:GLOBAL.TEMPDRIVE||'\EXFOL\ null goto batend \n');
    client_Text_IO.PutF(out_file,'mkdir '||:GLOBAL.TEMPDRIVE||'\EXFOL \n');
    client_Text_IO.PutF(out_file,':batend \n');
    client_Text_IO.fclose(out_file);
    synchronize;
    CLIENT_host('cmd.exe /c '||:GLOBAL.TEMPDRIVE||'\chkdirz.bat',NO_SCREEN);
    END;

    christian erlinger wrote:
    When you want to print out an escape character in java (java is doing the work in client_text_io ), you'd need to escape it.
    client_text_io.put_line(out_file, replace('your_path', '\','\\'));cheersI tried replacing \ with double slash but it just printed double slash in the bat file. again the path was broken into two lines.
    file output
    chdir C:\\DOCUME~1\
    195969\\LOCALS~1\\Temp\
    Edited by: rivas on Mar 21, 2011 6:03 AM

  • Administrators unable to write to a text file created by another Administrator on Windows Server 2008.

    Why are Administrators unable to write to a text file created by another Administrator on Windows Server 2008?
     --- The Administrators already have full control so how do I fix this? ---
    Example:  On a Windows Server 2008 (SP1): user A (who belongs to the Administrators group) logs in and creates a directory C:\foo and creates a file readme.txt in the foo directory.  User B (also a member of the Administrators group) logs in and opens C:\foo\readme.txt in notepad. User B types something and tries to save the file. User B cannot save the file…an option to save as some other file name is presented. The security permissions of C:\foo\readme.txt show that Administrators have full control.  
    Work around 1: Explicitly add user B to have full control over the foo directory. The problem is that all the all other Administrators still need to be added (current and future).
    Work around 2: Change the Users security permission to be full control on the foo directory. (this seems dangerous!)
    It is interesting to not that this same procedure is not a problem in Windows Vista. (Any insight about the difference?)
    Sincerely,
    Ian 

    so there is no way to change this without literally shutting down the UAC?
    I have files that  I need to modify all the time, and it is very annoying to have to save as to my desktop modify and then copy and paste the file again.
    I would also rather not give myself permissions to the entire C:\ Drive even specified Folders or documents, etc......
    You can change these settings without bringing down the UAC
    <!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-fareast-font-family:Calibri; mso-bidi-font-family:"Times New Roman";} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt; mso-ascii-font-family:Calibri; mso-fareast-font-family:Calibri; mso-hansi-font-family:Calibri;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} -->
    1.    Click Start, type gpedit.msc and press Enter.
    2.    Expand Computer Configuration -> Windows Settings -> Security Settings -> Local Policies -> Security Options.
    <!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-fareast-font-family:Calibri; mso-bidi-font-family:"Times New Roman";} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt; mso-ascii-font-family:Calibri; mso-fareast-font-family:Calibri; mso-hansi-font-family:Calibri;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} -->
    3.    Double-click “User Account Control: Behavior of the elevation prompt for administrators in Admin Approval Mode” on the right pane.
    a.    Choose “Elevate without prompting” and click OK.
    b.    Double-Click “User Account Control: Admin Approval Mode for the Built-in Administrator account”, Click Enable, Apply and then OK
    c.     Double-Click “User Account Control: Run all users, including administrators, as standard users”,Click Enable, Apply and then OK
    Then reboot the Server. You should now have the ability to modify any document, etc....

  • Write and read txt files and catch the exceptions

    hey everyone, im in a bit of a bind. im trying to set up this try catch statement. here is what i have for code so far.
    import java.util.Scanner;
    import java.io.*;
    public class Warning
        //   Reads student data (name, semester hours, quality points) from a
        //   text file, computes the GPA, then writes data to another file
        //   if the student is placed on academic warning.
        public static void main (String[] args)
         int creditHrs;         // number of semester hours earned
         double qualityPts;     // number of quality points earned
         double gpa;            // grade point (quality point) average
         String line, name, inputName = "students.dat";
         String outputName = "warning.dat";
         try
              Scanner FileScan1 = new Scanner (new File("students.dat"));
              // Set up scanner to input file
              // Set up the output file stream
              // Print a header to the output file
              outFile.println ();
              outFile.println ("Students on Academic Warning");
              outFile.println ();
              // Process the input file, one token at a time
              while (FileScan1.hasNext())//there is another line...
                  {               // Get the credit hours and quality points and
                   // determine if the student is on warning. If so,
                   // write the student data to the output file.
              // Close output file
         catch (FileNotFoundException exception)
              System.out.println ("The file " + inputName + " was not found.");
         catch (IOException exception)
              System.out.println (exception);
         catch (NumberFormatException e)
              System.out.println ("Format error in input file: " + e);
    }I am pretty sure the layout is good to go, but first and foremost that try statement is hanging me up. Could someone give me some suggestions about how i should set this up.
    i want to read in this students.dat file, then output another file called warning.dat.
    Thanks i really appreicate the help.

    no, i was really hoping to just see if the way it is
    set up it will be doable, that way i wouldn't be
    working on code that was impossiable to sort through
    properlyFair enough.
    One thing I'd suggest is that if you're really basically only going to be printing the exceptions, and since that is the top-level method (main) --
    I'd instead just add some "throws" clauses to main, get rid of the try/catch stuff, and just let the VM handle the exceptions for you. It will print them, just like you're doing, except that it will also print the stack traces, which you are not doing.
    If you're going to handle exceptions, it's better to actually do something about them rather than just print them - otherwise you might just as well let the runtime do that for you.

  • TS1717 unes, i have windows 8, i get the message, "the itunes Library .itl file is locked, on a locked disk, or you do not have write permission for this file.  how did this happen, how do i fix this?

    the message"The itun, library .itl file is locked, on a locked disk, or you do not have write permission for this file". i have windows 8. how why did this happen? how do i correct this and prevent another occurance?  I am able to access itunes on my i5, ipad, and my old i4 that i use solely as my ipod now. At the time  problem occurred, i was connected to ext hard drive that hold over 190GB music, to add to my library. I am now unable to add to my library using my laptop.  any advise/help is greatly appreciated!!

    I just had the same problem and was able to fix it after trying a couple of things I found after a search.
    The solution that worked for me:
    Find iTunes folder - it should be in C:\Program FIles (x86) or similar depending on your operating system
    Right click the entire folder (no need to open it) and click properties
    Click the security tab
    Click edit and highlight the user name under which you logged in.
    Click the box next to full in the allow column, which should check everything
    Click apply
    Open iTunes
    This worked for me.

  • How To Fix: "The iTunes Library.itl file is locked, on a locked disk, or you do not have write permission for this file."

    I can't reopen my iTunes after I have to force quit when it does not respond. I get this message:
    "The iTunes Library.itl file is locked, on a locked disk, or you do not have write permission for this file."
    I've read to do the solutions. I right clicked on both the iTunes and Music folder and went to info for each. On both the lock at the bottom of the Get Info was locked. All of my users including admin can read and write all files within those folders. They are even a shared folder. I clicked on the lock to unlock it, typed in my admin password, and went to the gear to apply to all files inside. After doing that I keep getting the saved message.
    I tried another way that I've found online to move my ituneslibrary folder to the desktop and then open my iTunes. In theory the iTunes is supposed to ask for where the iTunes library is. Once that is prompted you quit iTunes and drag the iTunes Library folder back to the folder from the desktop and reopen iTunes to apprently solve the problem. However, when I move the iTunes Library file to the desktop and try to reopne iTunes the icon just keeps bouncing and when I right click the application does not respond.
    This problem is only resolved if I restart/shut down my macbook pro which is a 15-inch Core 2 Duo with intel. It will be 5 years old in December. I currently have Lion and the latest iTunes 10.5. This problem started in late December. 

    If you hold down the option key when starting iTunes, it will allow you to select a library or create a new one.
    You can create a new one, and then add all of your iTunes music back in by simply dragging the old iTunes music file onto iTunes.
    There are more detailed instructions at http://support.apple.com/kb/HT1451#
    It will show you how to re-build your iTunes database file.

  • Write Access to a file in Tomcat server via J2me Midlet

    How to make write access to a file using midlet and HTTP connection?
    I have text file in the Tomcat server and I am able to read it with HTTP connection using emulator, but don't have idea how to make write access to the file. I'd like to write some text to the file.

    Thanks, but could you be more accurate. What methods should I use in the servlet and what methods in the midlet?
    Some links which concern this subject, would be nice too. I have tried with google, no success.

  • ITunes won't open, I get this message: The iTunes Library .itl file is locked, on a locked disk or you do not have write permission for this file.

    iTunes won't open.
    I get this message: The iTunes Library .itl file is locked, on a locked disk or you do not have write permission for this file.

    This may indicate a corrupt preference file with iTunes trying to open the wrong location. Try holding down shift as you launch iTunes then choose the correct file, normally <User's Music>\iTunes\iTunes Library.itl. See iTunes: How to open an alternate iTunes Library file or create a new one.
    tt2

  • HT1527 iphone wont open it says the itunes library.itl file is locked on a locked disk or you do not have write permission for this file. nothing l  do seems to help thanks

    Have tried to connect and sync my iphone 4 to my computer in itunes but this message keeps coming up The itunes Library .itl file is locked on a locked disk. or you do not have write permission for this file.

    I have tried both suggestions, unfortunately neither fixed this for me. Hoping there's another possible fix. Thanks in advance. 
    Empty/corrupt iTunes library after upgrade/crash and/or Repair security permissions for iTunes for Windows.

  • Opening photoshop from double click on file opens the app but doesn't open the file.

    This is a new behaviour... how can we solve it? Its very annoying!

    Thanks!
    Steps to reproduce:
    Having the photoshop closed...
    1 - Double click a psd file on the desktop (or any other place)
    2 - Photoshop loads until it gets to the normal window
    3 - The file wasn't opened
    4 - Go back to the desktop and double click the file
    5 - Photoshop (that is at this time already open), opens the file and displays it on screen
    Shouldn't it be opening the file after loading photoshop?
    details on my macbook and photoshop versions attached

  • Data Acquisition - using local variables to write data to a file

    Hello,
    I am running a Data Acquisition vi (currently in LabVIEW 7.1 but soon to be updated to 8.2) that collects ~100 parameters of data from several sources contained in a while loop. The current configuration (which I did not write) uses very few subVIs and writes to ~100 local variables to store each parameter. It then reads all the local variables and builds an array of all the strings, converts then to a spreadsheet string, then uses the write characters to file function to append to a datafile. I am trying to clean things up and have came up with subVIs to collect the data from the following sources:
    8 serial port sources collecting btwn 8 and 20 parameters each
    ~15 thermocouple readings
    ~10 analog inputs
    ~20 parameters read off an ARINC 429 bus.
    I have come up with a subVI to read each of the sources and have placed the subVIs in the while loop. Each subVI outputs the data that it collects in array or cluster form. I was wondering how best to write each parameter to a CSV file at between 1 and 10 Hz. Should I write each subVI output to a LV and then read them off as was done before (the difference being that I have reduced the # of LVs to ~10 vs >100?
    I should add that precise timing is not that important, so if all the subVIs are not collecting simultaneously (which I understand that they won't be), it does not really matter.
    Thanks.

    Hi jilla,
    jilla wrote:
    What I think that you are saying is to turn the outputs of the 4 subVIs into inputs of a 5th subVI that writes to the data file. Correct?
    Yes.  It may sound like a fine-point, but I beileve it's better to create a VI specifically for formatting data - in your example, 4 arrays IN, a single string OUT.  Then write the string to file as a seperate operation.  GUI-displayed data can go through a similar transformation, the four arrays wired to a subVI which builds output-structures specifically for display.  It's a beginner's mistake to put lots of individual controls and indicators on the screen when groups of them are naturally related (in an object-oriented sense.)  Use clusters to group related controls - this will keep the diagram much cleaner.
    One more question: at what point (either # of data points or frequency of data collection) does it become necessary to use queues? Thanks.
    Well, there's not really a clearly definable "point".  I'd say if your update-rate climbs above 100Hz, or you witness poor program or system performance, then it's time.  The scenario you've described is a fairly simple acquire/display&log loop - and simple is good.   Then-again people can't see/react-to updates faster than about 10Hz - so it doesn't make sense to sacrifice performance - if performance becomes an issue.
    Re: queues:  Queues are sometimes used to buffer data that's "produced" in one place and "consumed" in another.
    Here, if/when logging data, you're logging with every DAQ.  I wouldn't recommend using a queue to transport data from a "DAQ loop" to a "Logging-loop" - those functions can be in the same loop.  Should/could a queue be used to get data from a "DAQ loop" to update the GUI at a lower frequency?  Sure, but a Notifier might be a better choice.   Further, in the (simple?) program you've described, you might use a case structure (True/False) to only update FP indicators every "X" iterations - a simple solution that doesn't require Queues or Notifiers.
    Cheers!
    "Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)

  • My iTunes won't open! It keeps saying 'The iTunes Library.itl is locked on a locked disk or you not have write permission for this file.' Please Help!

    My iTunes won't open! It keeps saying 'The iTunes Library.itl is locked on a locked disk or you not have write permission for this file.' Please Help!

    this may happen on external drives if:
    The external drive was hotpluged (removed) without going the correct "eject" way
    The iTunes library (database) got corrupted
    First Aid for external drive
    Close iTunes
    Unmount (eject) external drive the right way.
    Mount drive again
    Go to Workplace -> right click external drive -> choose "clean up" This will force the filesystem to rescan the file structure of the drive and rebuilding the file system table and journaling file.
    After the tool shows "done" (could last some time depending on size of drive) restart iTunes
    If your iTunes library is on your internal drive, this may happen
    The system was not shoot down correct, e.g. "pulled the plug"
    The iTunes library (database) got corrupted
    First Aid for internal hard drive
    Close iTunes
    Reboot system
    Go to Workplace -> right click external drive -> choose "clean up"
    After the tool shows "done" (could last some time depending on size of drive)
    Reboot system, restart iTunes
    If none of the above fixes your problem, post here.
    Lupunus

  • How Can I Simulate Double-Clicking A File To Open It In The Default App Without Installing Default App?

    I have an app written with Visual Studio 2013. The app has code for opening a file using the standard OpenFileDialog and also has code (AutoOpenFile()) for opening a file when a user double-clicks on a file that is handled by the app. I have not yet created
    an installer for the app, so I won't be able to test it's AutoOpenFile() code...unless there is a way to simulate the process of auto-opening the double-clicked file without actually installing the app on my PC. Anyone?

    Thanks for your reply, Wyck. I already have the necessary code in my app for opening a file when I double-click on it. The problem is that the app is not currently installed on my PC. Until I do install it, is there a way I can test-run that code
    by double-clicking on an associated file?
    You lost me at: you want to test-run code that is not on your PC.
    O_o
    You want to double-click a file, and then...what do you want to have happen?  You want to run...something...that is not on your PC??
    The "simulation" is to launch your app from the command line and pass in the name of the file you wanted to simulate a "double-click" of.
    Regardless, you cannot get the shell to have a double-click of a file cause your application to launch unless you modify the registry to do so.  (This is tantamount to "install" to me.)
    In the spirit of continuing to be helpful, though, I'll assume that this is what you want to do and I'll show you how to get it done with the least amount of tampering with your registry.
    Here are minimally invasive registry modifications you need to make to get it to launch a program when you double-click your file.  It's pretty small.
    EXAMPLE ONLY:
    Windows Registry Editor Version 5.00
    [HKEY_CLASSES_ROOT\.wyck]
    @="Wyck.Document"
    [HKEY_CLASSES_ROOT\Wyck.Document\shell\open\command]
    @="c:\\windows\\system32\\notepad.exe \"%1\""
    [You have to save the above with your appropriate modifications to a file with the
    .reg extension (e.g.: test.reg) and then you'll have to double-click the test.reg file to "merge" these settings into your registry.]
    The example above registers a file extension called .wyck and assigns a completely arbitrary class name to it called
    Wyck.Document.
    Then it associates a shell open command with the Wyck.Document class that causes
    notepad.exe to be passed the filename of the file you double-clicked (that's what the
    %1 does).  You are welcome to replace all the specific names with your own extensions and class names and replace notepad.exe with the path to your (test) executable.
    This executable will be launched, but not with a debugger attached.  To facilitate debugging it, you'll want to temporarily add some code to your program to pause when the program launches, possibly by showing a message box right at the very beginning
    of your main function that says "attach debugger now" so that you can attach a debugger to the process that was started by the shell, and then dismiss the message box and continue debugging.
    When you are done with your testing, you can simply manually delete those two registry keys using
    regedit.

  • How to write to a log file within a JSP

    Hello everybody,
    do you know how to write to a log file within a JSP.
    my code is (/space/SP/tlf/ExcepcionJava.jsp):
    <html>
    <body bgColor=#C4E1FF>
    <%@ page import="java.io.*" %>
    <%
         FileWriter salida = new FileWriter(response.encodeURL("log.txt"));
         salida.write(request.getParameter("errorMsg"));
         salida.close();
    %>
    </body>
    </html>.. I run under Solaris, Jrun 2.3.3
    I have also test with getServletContext().getRealPath(), but I get /netsrv/nes/docs/ instead of /space/SP/tlf/

    Hi,
    Give the full path of the log file to the FileWriter. Such as;
    FileWriter salida = new FileWriter(response.encodeURL("/usr/local/tomcat/logs/testlogs/log.txt"));
    nurettin

  • Need example with write to DATA log file programmatically?

    Hi all,
    I would like to request for an example of writing a datalog (*.DAT) file which could do this.
    Datalog file.
    NAME: AGE: SEX: (header)
    john 16 M (data)
    marie 55 F
    Dolah 34 M
    The program can also let me to add in new data and then store in the same file.dat. The data (hopefully) can be written to the bottom of the last saved entry of data. (eg. after the row Dolah).
    I need to do this so that I can open and read back the datalog file and use the data for other purpose.
    Please help,
    juni

    You've got some examples in Fundamentals>File Input and Output but one of the easiest things to do is to modify Write Strings to Spreadsheet File.vi to write strings as detailed at the bottom of the diagram and then save it to a different place and with a different name.
    Attachments:
    Spreadsheet_File_Write.jpg ‏17 KB

Maybe you are looking for

  • How to get the data from AUSP TABLE

    Hi Experts, Select * from AUSP where atinn = w_attin                               And   klart = ‘001’                               And  atwrt between w_low  and w_high. Endselect. Here I am using this select to retrive data from ausp where atwrt in

  • Autofill form addon is missing page information to fill profile data

    to use autofill form add on you must enter data after selecting the simple icon. I selected the simple icon and no fields are available to fill out your personal data. I am using firefox 3.6.13 on my PC using window 7 Home premium. It was working up

  • Automatic emails to vendor before delivery date in PO

    Hi All, I have successfully done the configuration for auto emails to vendor, it will work based on the delivery date (AFTER), which is working fine. Please guide me the settings for auto emails to vendor (BEFORE) delivery date in PO. Example: In PO

  • Which version to download

    Hi, I used to have wlp10.3.4 on windows vista and oepe are installed with portal. Now I need to move to windows7 which is 64bit. Since the wlp generic install doesn't have jdk and oepe, I installed jdk (160_21 the same verison as the one in wlp10.3.4

  • 2 Ipods. 1 Computer. 2 Windows XP accounts. 1 Dilemma

    Hi, I have Windows XP, and a question. I have two differnt Ipod owners in my house, but only one computer. We have two different accounts on XP, but when we install and open Itunes on either one, the Library is the same. Both Ipod owners have diffent