Handling integers in files

Hi!!
In the code below I try to read a number and a String
to a file. But the number can't be extracted when
reading from the file again!
Why can that be?...;/
kR\\j*
import java.io.* ;
import java.util.* ;
public class TestaNu
     public static void main(String[] args)
          try
               File minFil = new File("sol.txt") ;
               FileWriter writer = new FileWriter(minFil) ;
               writer.write(1974) ;
               writer.write("Testing") ;
               writer.close() ;
               File minAndra = new File("min.txt") ;
               FileReader reader = new FileReader(minFil) ;
               FileWriter wri = new FileWriter(minAndra) ;
               wri.write(reader.read()) ;
               wri.write(reader.read()) ;
               wri.close() ;
               reader.close() ;
               Scanner sc = new Scanner(minAndra) ;
          catch (IOException ie)
               ie.printStackTrace() ;
}

You need to read the API:
http://java.sun.com/j2se/1.5.0/docs/api/java/io/Writer.html#write(int)
http://java.sun.com/j2se/1.5.0/docs/api/java/io/Reader.html#read()
               writer.write(1974) ;This statement doesn't write the four characters '1', '9', '7', '4' to the file.
It writes the single character \u07b6 (that's 1974 in hex) to the file.
I have no idea what character that is!
               reader.read() ;This expression reads the next character. One character! You seem to
be using it as a generic "read the next thing -- integer, string etc..."
I think what you should do is to sit down and come up with a file format,
especially if you will be mixing numbers and text, then realize that
reading from such a file will be an exercise in parsing.

Similar Messages

  • IE running under XP can't handle multiple SWF files, Why?

    I noticed that IE 8 running under Windows XP cannot handle multiple swf files in one page.
    Up to about 10 files is no problem they are loaded and we can play them ( buttons that start a small audio file).
    But more of these files in one page will stop IE.
    Firefox ( 3.6.28) runs them fine.
    And also IE 8 and/or Firefox under Windows 7 handles them perfectly.
    Has anyone any idea what can cause this and how to resolve this?
    Thanks,
    Onno Tomson
    The Netherlands

    Sorry...I still don't get it. What is it about Windows FUS that keeps iTunes from running running the process twice? It can run many other non-Apple windows apps in multiple user sessions (commercial apps, open source apps, audio/video apps, networked apps). I can even run two different virtual machines at the same time under two different user sessions.
    Why can iTunesHelper.exe run twice but iTunes.exe cannot? Why can I run Safari at the same time? Quicktime Player runs fine under multiple user sessions.
    Blaming it on Windows and/or FUS sounds like FUD. Can anyone give a valid technical reason? Semaphores? Mutexes? An admission (and explanation) that the Windows version is purposely crippled?

  • Problem about Handling of Empty Files in File Adapter

    Hello everyone,
    NetWeaver 2004s --- XI
    In Sender i have a File Adapter.
    Now i meet a problem about Handling of Empty Files. When i send empty file, but don't cerate a leer message.
    I have seen following text in help document. But in adapter configuration i can not find the correspond parameter.
    can you give me some tips?
    Thx in advance
    best regards
    Yaning
    SAP Help Document über File Adapter
    +Handling of Empty Files
    Specify how empty files (length 0 bytes) are to be handled.
    ○       Do Not Create Message
    No XI messages are created from empty files.
    The files are processed according to the selected Processing Mode.
    For example, if the processing mode is Delete, empty files are deleted in the source directory.
    ○       Process Empty Files
    XI messages are created with an empty main payload.
    The files are processed according to the selected Processing Mode.
    ○       Skip Empty Files
    No XI messages are created from empty files.
    Empty files are skipped and remain in the source directory.+
    Help Docu

    hi,
    it's available since Sp19 for XI 3.0
    and the corresponding SPS fpr XI 7.0
    http://help.sap.com/saphelp_nw04/helpdata/en/44/f565854b7341e6e10000000a1553f6/frameset.htm
    so probably you need to install the new SP
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

  • "Message Rejection Handler" for the file/ftp adapter using fault policy

    Hi guys,
    We are trying to implement "Message Rejection Handler" for the file/ftp adapter using following fault policy configuration.
    Fault Policy:
    `````````````
    <?xml version='1.0' encoding='UTF-8'?>
    <faultPolicies xmlns="http://schemas.oracle.com/bpel/faultpolicy">
    <faultPolicy version="2.0.1" id="ProcessNameGenericPolicy"
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns="http://schemas.oracle.com/bpel/faultpolicy"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Conditions>
    <faultName xmlns:bpelx="http://schemas.oracle.com/bpel/extension"
    name="bpelx:remoteFault">
    <condition>
    <action ref="ora-retry"/>
    </condition>
    </faultName>
    <faultName xmlns:bpelx="http://schemas.oracle.com/bpel/extension"
    name="bpelx:bindingFault">
    <condition>
    <action ref="ora-rethrow-fault"/>
    </condition>
    </faultName>
    </Conditions>
    <Actions>
    <Action id="ora-retry">
    <retry>
    <retryCount>3</retryCount>
    <retryInterval>1</retryInterval>
    <retryFailureAction ref="ora-rethrow-fault"/>
    </retry>
    </Action>
    <Action id="ora-rethrow-fault">
    <rethrowFault/>
    </Action>
    <Action id="ora-human-intervention">
    <humanIntervention/>
    </Action>
    <Action id="ora-terminate">
    <abort/>
    </Action>
    </Actions>
    </faultPolicy>
    <faultPolicy version="2.0.1" id="ProcessNameHumanInterventionPolicy"
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns="http://schemas.oracle.com/bpel/faultpolicy"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Conditions>
    <faultName xmlns:medns="http://schemas.oracle.com/mediator/faults"
    name="medns:mediatorFault">
    <condition>
    <test>contains($fault.mediatorErrorCode, "TYPE_TRANSIENT")</test>
    <action ref="ora-retry-with-intervention"/>
    </condition>
    </faultName>
    <faultName xmlns:bpelx="http://schemas.oracle.com/bpel/extension"
    name="bpelx:remoteFault">
    <condition>
    <action ref="ora-retry-with-intervention"/>
    </condition>
    </faultName>
    <faultName xmlns:bpelx="http://schemas.oracle.com/bpel/extension"
    name="bpelx:bindingFault">
    <condition>
    <action ref="ora-rethrow-fault"/>
    <!--<action ref="ora-retry-with-intervention"/>-->
    </condition>
    </faultName>
    </Conditions>
    <Actions>
    <Action id="ora-retry-with-intervention">
    <retry>
    <retryCount>3</retryCount>
    <retryInterval>1</retryInterval>
    <retryFailureAction ref="ora-human-intervention"/>
    </retry>
    </Action>
    <Action id="ora-retry">
    <retry>
    <retryCount>3</retryCount>
    <retryInterval>1</retryInterval>
    <retryFailureAction ref="ora-rethrow-fault"/>
    </retry>
    </Action>
    <Action id="ora-rethrow-fault">
    <rethrowFault/>
    </Action>
    <Action id="ora-human-intervention">
    <humanIntervention/>
    </Action>
    <Action id="ora-terminate">
    <abort/>
    </Action>
    </Actions>
    </faultPolicy>
    <faultPolicy version="2.0.1" id="RejectedMessages">
    <Conditions> <!-- All the fault conditions are defined here -->
    <faultName xmlns:rjm="http://schemas.oracle.com/sca/rejectedmessages" name="rjm:PartnerLinkName">
    <!-- local part of fault name should be the service name-->
    <condition>
    <action ref="writeToFile"/> <!-- action to be taken, refer to Actions section for the details of the action -->
    </condition>
    </faultName>
    </Conditions>
    <Actions> <!-- All the actions are defined here -->
    <Action id="writeToFile">
    <fileAction>
    <location>Server/Loc/path</location>
    <fileName>Rejected_AJBFile_%ID%_%TIMESTAMP%.xml</fileName>
    </fileAction>
    </Action>
    </Actions>
    </faultPolicy>
    </faultPolicies>
    Fault Binding:
    ``````````````
    <?xml version='1.0' encoding='UTF-8'?>
    <faultPolicyBindings version="2.0.1"
    xmlns="http://schemas.oracle.com/bpel/faultpolicy"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <composite faultPolicy="ProcessNameGenericPolicy"/>
    <service faultPolicy="RejectedMessages">
    <name>PartnerLinkName</name>
    </service>
    <reference faultPolicy="RejectedMessages">
    <name>PartnerLinkName</name>
    </reference>
    </faultPolicyBindings>
    We have SyncFileRead partner link.
    The expectation is: when the message read by SyncFileRead partner link is rejected,
    that rejected message should come to particular directory in the server.
    Could you please help us fixing this.
    TIA.

    HI..
    Have a look at this blog :
    3) Error: HTTP_RESP_STATUS_CODE_NOT_OK 401 Unauthorized
    Description: The request requires user authentication
    Possible Tips:
    u2022 Check XIAPPLUSER is having this Role -SAP_XI_APPL_SERV_USER
    u2022 If the error is in XI Adapter, then your port entry should J2EE port 5<System no>
    u2022 If the error is in Adapter Engine
    u2013then have a look into SAP note- 821026, Delete the Adapter Engine cache in transaction SXI_CACHE Goto --> Cache.
    u2022 May be wrong password for user XIISUSER
    u2022 May be wrong password for user XIAFUSER
    u2013 for this Check the Exchange Profile and transaction SU01, try to reset the password -Restart the J2EE Engine to activate changes in the Exchange Profile After doing this, you can restart the message
    Http* Errors in XI
    Thanks,
    Pooja

  • Acrobat 4.0 possible patch to handle newer .pdf files?

    I am currently at a small printing company that uses a Heidelberg Prosetter and interconnected software programs for platemaking in our pre-press department. We currently have an outdated Heidelberg meta dimension system that I was told will only handle Acrobat version 4.0 files. I get errors when a newer .pdf version is sent to me from my customers. So far I have found work arounds such as saving the .pdf file down to a compatible file, but am running out of options, and the newest version 9.0 files are really giving me a headache. Saving the file down doesn't seem to help. Is there a possible patch I can find to allow version 4.0 to handle the newest files? Heidelberg has told me that if we were to upgrade to a newer version of Acrobat we would need to upgrade the rest of our software (PitStop Server, Meta Dimension, SignaStation) since they all work together to burn plates and that would cost us upwards of $25,000. Being a small company we can not afford this and the owners have basically told me to work with what I have. Can anyone help me?

    I still keep having some issues with transparent objects and drop shadows with a spot colors. I just spoke to our Heidelberg rep and he mentioned that they even had to update their software to handle the 9.0, and are now recommending that customers upgrade to the newest version of Meta Dimension (which is very costly I might Ad!). I think I am just stuck between a rock and a hard place, and will be there as long as I work here! Not only do I have issues with the transparent objects, I am sometimes getting a flat out will not open error message in EnFocus PittStop which is our pre-flight software. I am going to have to post this on the EnFocus forums and hope that someone might be able to solve that for me. Thanks for the input. I kind of thought that a patch like that was out of the question! There is just no help for poor people like me!

  • Where is the Error-Handler config DB file?

    Where is the Error-Handler config DB file?
    <P>
    All the Config DB files are in the config directory under the
    postoffice directory. Each config file has the same name as the
    Module it's the config for (e.g. Error-Handler contains the configs
    for the Error-Handler.)

    Look in the database alert file - in the "bdump" directory
    Look in the trace files in the "udump" directory
    If still no wiser:
    ALTER system SET event = '31098 trace name context forever, level 2' scope=spfile
    Try again and look for the trace files starting with "s..." in the "udump" directory.

  • Handling tar.gz files

    Hi all,
    I am looking to get PHP up and running on my Mac I found the PHP modules on http://www.entropy.ch/software/macosx/php/ which was linked directly from php.net.
    The tutorial for installation says NOT to use Stuffit but to use BOMArchiveHelper instead to unpack the installation files.
    I have clicked "get info" on my php-5.2.1.tar.gz file and chose BOMArchiveHelper to open the file.
    Problem is when I double click the file a second archive is created, it is compressing again instead of unpacking!
    Any help with this will be greatly appreciated. A second option could be if you can point out a tutorial for correctly handling any compressed file from the command line.
    Thanks in advance.
    Juan

    Juan:
    Try this. Create a new folder in your desktop (let's say you called it PHP) and put your archive in there. Then open the terminal (in Utilities) and change directories to the new folder:
    cd ~/Desktop/PHP
    Then, extract the archive with
    tar -xzvf php-5.2.1.tar.gz
    That should decompress and unarchive the contents of the "tarball" into the PHP directory. We created the PHP directory only to prevent a potential large number of files loose in your desktop.
    Good luck,
    Juan-Pablo

  • RE: Customized Express process handling '(I/O files toworkspaces)'

    J-Paul,
    We have the same problem., We just export the specific project files and
    export them. First load them before you load the .WEX file. We had some
    express experts on site and they could not give us another solution!
    Hans van Drunen
    Origin DeskTop Business Solutions Rotterdam
    Admiraliteitskade 60, 3063 DC Rotterdam
    Telefoon : 010 - 242 81 00
    Fax : 010 - 242 81 81
    -----Original Message-----
    From: J-Paul GABRIELLI [mailto:[email protected]]
    Sent: Thursday, January 28, 1999 10:09 AM
    To: Forte-Users (Adresse de messagerie)
    Subject: Customized Express process handling '(I/O files to workspaces)'
    Hi,
    I'm working with exported workspace (wex files), and didn't find a way to
    include in such a file the
    customized version of the Express Projects we currently use.
    Is there a specific flag to set ?
    Thansk,
    J-Paul Gabrielli
    Software something :)
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    J-Paul,
    We have the same problem., We just export the specific project files and
    export them. First load them before you load the .WEX file. We had some
    express experts on site and they could not give us another solution!
    Hans van Drunen
    Origin DeskTop Business Solutions Rotterdam
    Admiraliteitskade 60, 3063 DC Rotterdam
    Telefoon : 010 - 242 81 00
    Fax : 010 - 242 81 81
    -----Original Message-----
    From: J-Paul GABRIELLI [mailto:[email protected]]
    Sent: Thursday, January 28, 1999 10:09 AM
    To: Forte-Users (Adresse de messagerie)
    Subject: Customized Express process handling '(I/O files to workspaces)'
    Hi,
    I'm working with exported workspace (wex files), and didn't find a way to
    include in such a file the
    customized version of the Express Projects we currently use.
    Is there a specific flag to set ?
    Thansk,
    J-Paul Gabrielli
    Software something :)
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

  • Pacman Handling of Configuration Files

    Hello,
    This morning Arch welcomed me with a few problems as usual. The thing I noticed for the first time was a weird handling of configuration files. After rebooting my computer I realized X11 didn't get up. I realized that pacman has replaced /etc/inittab (and saved the old one with /etc/inittab.pacsave). And worst of all a quick diff shows that nothing of importance actually changed in inittab.
    Now, I believe this kind of behaviour is not acceptable. This could easily render a machine unusable (just think of complicated reinstallations on mini laptops without bootable cd-roms, etc)... Or imagine setting up somebody's computer to boot up in X, and having the person be welcomed by a getty.
    To conclude, I believe that focus on a pacman -Syu should be on hassle-less updates, with as little risk of breaking anything. Thus, the default behavior (described in man as):
           original=X, current=Y, new=Z
                  All three files are different.  So we install the new file,  but
                  back  up the old one to a .pacsave extension.  This way the user
                  can move the old  configuration  file  back  into  place  if  he
                  wishes.
    should, in my opinion be the same like for:
           original=X, current=Y, new=X
                  Both  package  versions contain the exact same file, but the one
                  on the filesystem has been modified since.   In  this  case,  we
                  leave the current file in place.
    Or, at least, I think there should be an optional flag to change /etc files config conflicts behaviour. Rebuttals, please
    Maksim Sipos

    deja vu... did you or somebody else not post this exact message several months ago?  Or am I just mixing up past present and future again? :-D
    What I remember is this discussion coming up, somebody reminding the poster that there is a NoUpgrade option to allow specific files to not be overwritten in /etc/pacman.conf (for example: NoUpgrade = etc/inittab ). and Judd eventually making some kind of additional option to pacman to make it so that NoUpgrade is the default for something if that's what you want.
    I swear I've read your message word for word in the past.  I'm scared now... :oops:
    Dusty

  • Compressor's handling of .AVI files

    When you add an .AVI files to Compressor it takes a very long time for it to be added - the app actually seems for some time like it has frozen, but if you wait long enough it usually gets added. The same then happens when you apply the conversion process required.
    Is there any way Apple could improve Compressor's handling of .AVI files?

    Umm ... Apple doesn't support AVI. Flip4Mac adds that ability. I too really wish Flip4Mac would convert even faster ... but that's an issue with them, not Apple. (The latest Flip4Mac beta came out last week and it is much better than than the last.)

  • Thoughts on how LabVIEW handles checkout of file from SCC when file already open

    When you already have a file/project open in LabVIEW and it is set to read only because you haven't checked it out, you can go into SCC and do a checkout then save the file immediately. The issue with this is, if your local copy doesn't match the copy in SCC, you will probably be overwriting changes. Sometimes this is convenient because if you have ever edited a MS Word file and then gone to save and it won't let you because it was opened as read-only...then that sucks because you either lose your work, or have to do a copy of the entire word file->close the program->re-open as writable, then paste. This can be avoided with the "LabVIEW way", but the "MS Word" way seems much safer because it forces you to conscioiusly make the file writable (by either checking it out or manually write clicking and changing to writable) BEFORE opening it. I just wanted people's opinions on how LabVIEW handles this, and if there would be a better way.
    CLA, LabVIEW Versions 2010-2013

    VSS 
    CLA, LabVIEW Versions 2010-2013

  • I don't have pdf documents listed as a file type in the applications drop down menu so I cannot manage the handling of these file types. How do I get the pdf file recognised?

    I don't have pdf documents listed as a file type in the drop down applications menu, so cannot handle these. How do I add a file type?

    After a little Googling, it looks like B.Media is a content management system from Wave Corporation used for making catalogs. Doubtful you'd be able to license it at less than an enterprise level.

  • Logging with jdk1.4 - how to add a handler using configuration file

    Hi, all
    I am playing around with java.util.logging in jdk1.4. In particular, I am using a properties file for configuration. However, one thing I couldn't do is to assign a handler, such as the ConsoleHandler, to the com.xyz.foo logger. Everything for the root logger works just fine. Here's the file I use
    handlers= java.util.logging.FileHandler
    .level= INFO
    java.util.logging.FileHandler.pattern = jdk14.log
    java.util.logging.FileHandler.limit = 50000
    java.util.logging.FileHandler.count = 1
    java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
    java.util.logging.ConsoleHandler.level = INFO
    java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
    com.xyz.foo.level = WARNING
    com.xyz.foo.handlers = java.util.logging.ConsoleHandler
    Nothing comes out on the console and everything from the com.xyz.foo logger is logged to jdk14.log file.
    Can any one tell me why the last line has no effect?
    Thanks much!

    Logger configuration files are grossly misunderstood due in large part to extremely poor documentation (some of the worst I have ever seen for the Java platform). The LogManager class uses logger configuration files to do three things:
    1. Load porperties into a private Properties object that application programmers can subsequently access using the getProperty(String name) method in LogManager.
    2. Those properties (or else the documented defaults) are then used to configure the root logger as well as the "global" handlers that are used by the root logger
    3. Finally, whenever a logger is created the Properties object is checked to see if a key exists for the logger name + ".limit". If so, then the logger is assigned that level.
    Notice that nowhere in here does it say that a programmatically created logger is configured. In your case, you must invoke getProperty("com.xyz.foo.handlers"), parse the property value (which is a bit tricky if there is more than one handler class name), load and instantiate the handler class, and invoke addHandler. Great huh? I'm in the middle of a indepth study of logger configuration, and I can tell you for sure the static configuration using configuration files is an order of magnitude harder than dynamic configuration. It offers the advantage of field service engineers being able to change the logger configuration, but at a very significant cost.

  • How to create and handle a text file in CVI

    Is there any way to create and handle (like...open,write,read,truncate,close)  the .txt file in CVI?

    Sure. CVI is a regular C compiler and hence you can use all ANSI C functions. In addition you can use the File I/O functions from the utility library.

  • How to handle the remote files in servlets

    Hi all,
    I want to handle the file remotely in a server side class file by giving the realtive path , let us say some thing like
    File f = new File("http://localhost:8080/images/");
    here images is a directory, my requirement is to get all the image names in the folder.

    you don't have to do it through the network layer...
    check the servlet context doc
    http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/ServletContext.html
    (specially the getRealPath an getResource methods
    It helps you to know where you are on the localfilesystem, then you can retrieve the files you want

Maybe you are looking for

  • WiFi-Automatic network switching with OS 5.0.0.461?

    There was a previous version of OS 5 (I don't remember which one) that I was using with the 8900 that seems to connect to known WiFi networks automatically for me. For instance, once I've connected to my home and work WiFi networks (at least once), i

  • Can't receive email with large attachment​. why?

    A friend sends an email to me with a large attachment. It is rejected and he gets the following response. {edited for privacy}: 206.46.232.11 failed after I sent the message. Remote host said: 552 5.3.4 a message size of 20483 kilobytes exceeds the s

  • New source system

    We've just copied the BW Production system onto a new server (Test BW). The BW Production is pointing to Production ECC6. We're have created a new RFC in the Test BW, which point to Test ECC system. We have also perform the source system conversion v

  • Smart view -Offline Dataforms can have Business rules,Cell Text ,Supporting

    Hi Gurus, Does the Offline Data form is having the Business Rules, Cell Text,Supporting Details if the original Dataform having all those.If yes how they can be retrived in Offline Dataform. Thanq

  • Need help guide overclocking newbie msi p43 neo

    Hello i just wanted to ask for guide help tutorial ( no OC experience)  on how to do a mild overclock my cpu e7400 + (msi p43 neo) my main goal is 3.0 Ghz with a 1333 fsb. Im still researching guides but its still a bit complicated. My concerns are o