File stream question

I need to read characters or integers from a .txt file and do some calculation to the integer or do something to the characters.
taken from tutorial
import java.io.*;
public class Copy {
public static void main(String[] args) throws IOException {
     File inputFile = new File("farrago.txt");
     File outputFile = new File("outagain.txt");
FileReader in = new FileReader(inputFile);
FileWriter out = new FileWriter(outputFile);
int c;
while ((c = in.read()) != -1)
out.write(c);
in.close();
out.close();
i need to read in the integers from a .txt file and put it in an array. example
in the somenumber.txt file.
12 34 1
1 3
12 23
Question 1: Is there a way to convert the code from .txt file to an int?
Question 2: What code is the .txt represented in? ANSI? unicode? Is there a URL for the code-table?
Question 3: is the character a in the text == char 'a' ?

The character encoding of a file is independant of the java virtual machine. If you use the FileReader and FileWriter classes, I believe they use the default system encoding. If you know the format of the file then you should be able to do what you want fairly easily. You can use the StringTokenizer class to break up the lines of the file and use Integer.parseInt() to convert the string representations of number into their binary equivalent. Also, if you are using Java 1.4, you may be able to use regex to break the text up and verify proper format at the same time. This would save you the trouble of checking for a NumberFormatException when you call Integer.parseInt()

Similar Messages

  • Photo stream questions, sharing, etc.

    Shared photo stream questions
    Camera Roll (CR), Photo Stream (PS)
    If I create a shared PS and share it with a friend, is this temporary like the main PS (most recent 1000 images)?
    For example, if I put one photo in a shared PS and then take 1000 new photos (but I don't add it to the shared PS), presumably it will disappear from my main PS, but will the original photo disappear from the shared PS, too?
    I noticed that each month I have a new monthly event titled, for example, "August photo stream", etc. Are these temporary, too? If I take 1000 photos in September, will the August PS event start to lose images, or will this only occur in the main PS section?
    Apple's web site says "iCloud stores new photos for 30 days, so you have plenty of time to connect your iOS device to Wi-Fi and make sure you always have your most recent shots handy." What does this mean? If I take a photo on iPhone it's permanently in CR (until I sync with iTunes on OS X and then iPhoto offers to remove them from CR), but they're also in PS, which is temporary, right? If so, as long as CR is permanent, how big an issue is the 30 day rule?
    Here's where I'm (further) confused...
    On iPad, my PS section (the tab on bottom) only has 30, relatively recent photos. Each photo was taken with iPhone.
    However, on iPhone, my PS section has 547 images. Some of these were taken as screen shots from iPad (even though they're not on iPad's PS??) Some of the images were "Save As... "  image files from OS X, some were photos imported to desktop iPhoto from a camera. Many of the images were taken years ago. On desktop iPhoto, I have over 3000 images, but the images on iPhone's PS do not appear to be the most recent 1000 images imported to iPhoto.
    So why did iPad's screen shots disappear from iPads PS yet appear on iPhone's PS?
    Why aren't the two iOS device's PS sections the same?
    Is this confusing to everyone, or am I just dense?
    Thanks!

    You are most likely using the same apple id under settings>iCloud. If you just want to stop the photo sharing you can open settings>iCloud and turn off photostream. If you want to keep using photostream and still not share you need to set up an alternate apple id to use under settings>icloud

  • Http adapter -reading a http file stream

    Hi folks,
    Here is a requirement
    I need to read a file sent as an http object stream through XI and then updated the same in a database table in R/3?
    <b>How can i configure the http adapter so that it reads the file stream</b>
    regards
    krishna
    Message was edited by:
            Krishnamoorthy Ramakrishnan

    Thanks bhavesh
    Though your reply and reference did not directly answer my question, which i will explain below concisely, it did help me to get an idea about how to handle my requirement.
    Please read and give me your valuable advise.
    The sender is a distributor that wants to send some text file to a file server in XI.The sender will have to send the file as a http stream link. XI has to read the  file from the http stream and push it to a  file server in XI.  for this, i have identified that
    1. At outbound/sender side, there is an HTTP adapter in XI.
    2.The request to XI should be of the some think like
    <b>http://<host>:<port>/file stream.....</b>
    3. At inbound side , I have a java server proxy as suggested in the blog.
    4. The server proxy will use a http client connection to read the file stream and another ftp client to push it to the file server
    Do you think this would realize the requirement?
    I have also got a question here
    With the above mentioned URL, will the sender be able to communicate with XI, since the client is outside the network and has access to internet only. How can it communicate with XI?
    Also, Is there an better alternative to this approach?
    Thanks for your help
    Kind Regards
    krishna

  • JAVA opening file streams q

    ok my question is how to:
    1. open file stream
    save something (system)
    ensure it gets written onto a disk
    close open files!
    thanks

    http://java.sun.com/docs/books/tutorial/essential/io/index.html

  • Checkpointing - control file contents question

    Some clarification is needed if possible...
    When you commit a transaction:
    - commit scn is recorded in the itl of the data block and undo segment header
    - lgwr records the committed scn (for all data blocks involved) to the redo log
    Checkpoint Event
    - (3 seconds or possibly less passes by) CKPT wakes up and signals DBWn to write dirty (modified and committed)
    blocks to disk
    - CKPT records the scn of those blocks in the control file (data file and redo thread sections) and the data file
    header (task of checkpoint when a log switch occurs)
    - Checkpoint position in the Redo Log is forwarded
    Control file contents question:
    When LGWR writes the commit scn to the redo log, who writes the scn to the control file? LGWR or CKPT?
    Also, when is the redo thread scn written?
    Matt

    Matt,
    This is my understanding of the stuff. Feel free to correct me.
    Checkpoint SCN , as I mentioned in my last reply is the marker of the point till which the data is "chekpointed" to the datafiles. This marker tells the controlfile that in the case of the crash, where to start recovery of the datafile and have to go which extent in the redo stream? This is only available in the datafile header and in the controlfile. This doesn't get recorded in the redo log file/stream.
    I mentioned checkpoint queue in my reply too. Though I couldn't find any reference directly mentioned between this and in the checkpoint SCN but I believe my theory , if not totall, partially is correct. The incremental checkpoint is the stuff which makes the decision that how many redo blocks needs to be applied to the datafile if its closed without a proper checkpoint. So this part is maintained in the Datafile header itself in the form of the checkpoint SCN. When not matched with the conrolfile checkpoint SCN, which is always higher than this, a recovery is reported.
    I hope its somewhat correct. Do let me know your views too.
    Cheers
    Aman....

  • I got new hard driver for my MacBook I don't have the cd but I do have flash drive that has the software I need help because when I turn on my laptop it shows me a file with question mark how can I install the software from the flash driver?

    I got new hard driver for my MacBook I don't have the cd but I do have flash drive that has the software I need help because when I turn on my laptop it shows me a file with question mark how can I install the software from the flash driver?

    Hold down the Option key while you boot your Mac. Then, it should show you a selection of devices. Click your flash drive and it will boot from that.

  • How can I read a binary file stream with many data type, as with AcqKnowledge physio binary data file?

    I would like to read in and write physiological data files which were saved by BioPac�s AcqKnowledge 3.8.1 software, in conjunction with their MP150 acquisition system. To start with, I�d like to write a converter from different physiodata file format into the AcqKnowledge binary file format for version 3.5 � 3.7 (including 3.7.3). It will allow us to read different file format into an analysis package which can only read in file written by AcqKnowledge version 3.5 � 3.7 (including 3.7.3).
    I attempted to write a reader following the Application Note AS156 entitled �AcqKnowledge File Format for PC with Windows� (see http://biopac.com/AppNotes/ app156Fi
    leFormat/FileFormat.htm ). Note the link for the Mac File format is very instructive too - it is presented in a different style and might make sense to some people with C library like look (http://biopac.com/AppNotes/ app155macffmt/macff.htm).
    I guess the problem I had was that I could not manage to read all the different byte data stream with File.vi. This is easy in C but I did not get very far in LabView 7.0. Also, I was a little unsure which LabView data types correspond to int, char , short, long, double, byte, RGB and Rect. And, since it is for PC I am also assuming the data to be written as �little endian� integer, and thus I also used byte swap vi.
    Two samples *.acq binary files are attach to this post to the list. Demo.acq is for version 3.7-3.7.2, while SCR_EKGtest1b.acq was recorded and saved with AcqKnowledge 3.8.1, which version number is 41.
    I would be grateful if you someone could explain how to handle such binary file stream with LabView and send an example to i
    llustrate it.
    Many thanks in advance for your help.
    Donat-Pierre
    Attachments:
    Demo.acq ‏248 KB
    SCR_EKG_test1b.acq ‏97 KB

    The reading of double is also straight forward : just use a dble float wired to the type cast node, after inverting the string (indian conversion).
    See the attached example.
    The measure of skin thickness is based on OCT (optical coherent tomography = interferometry) : an optical fiber system send and received light emitted to/back from the skin at a few centimeter distance. A profile of skin structure is then computed from the optical signal.
    CC
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Read_AK_time_info.vi.zip ‏9 KB

  • How can I read a binary file stream with many data type, as with AcqKnowled​ge physio binary data file?

    I would like to read in and write physiological data which was saved by Biopac�s AcqKnowledge 3.8.1 software, in conjunction with their MP150 acquisition system. To start with, I�d like to write a converter from different physiodata file format into the AcqKnowledge binary file format for version 3.5 � 3.7 (including 3.7.3). It will allow us to read different file format into an analysis package which can only read in file written by AcqKnowledge version 3.5 � 3.7 (including 3.7.3).
    I attempted to write a reader following the Application Note AS156 entitled �AcqKnowledge File Format for PC with Windows� (see http://biopac.com/AppNotes/app156FileFormat/FileFo​rmat.h
    tm ). Note the link for the Mac File format is very instructive too - it is presented in a different style and might make sense to some people with C library like look (http://biopac.com/AppNotes/app155macffmt/macff.ht​m) .
    I guess the problem I had was that I could not manage to read all the different byte data stream with File.vi. This is easy in C but I did not get very far in LabView 7.0. Also, because it is for PC I am assuming the data to be written as �little endian� integer, and thus I also used byte swap vi.
    I would be grateful if you someone could explain how to handle such binary file stream with LabView and send an example to illustrate it.
    Many thanks in advance for your help.
    Donat-Pierre

    One more step...
    short are U16 integer
    double are double precision float
    bool seem to be 2 bytes (= U16)
    char are string (variable length)
    rgb are U16 integer, with high order byte = 0
    rect should be 4 x U16 (top, left, bottom, right)
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • SQL Server 2008 File Stream On Existing Table

    Hi Folks,
    I have enabled the SQL Server File Stream option on a Existing table.
    1. Created a GUID Column 
    2. Created a File Stream Column 
    3. Swapped the Blob Column information into file Stream column. 
    4. Dropped the BLOB Column. 
    I could evidence, The above Step 3 Process moved out all the Blob Data into an configured Network File Group.
    Ex:
    Existing BLOB Data Size --> 10 GB 
    Once after the completion of above step 4, SQL Server is not freeing up the BLOB occupied Space 10 GB. It should have only few MB's pointer address to the network file Group?
    If we create a new table with File Stream data type and insert the existing BLOB data ,Will result few MB pointer Address occupied in the newly created table. We except the similar behaviour for updating BLOB to File Stream in existing table. 
    Please advice me.
    Thanks 
    Narendran
    Narendran

    When you drop a column, SQL Server only mark the column as dropped, but does not reclaim the space, as that requires data to be shuffled around. You need to rebuild the clustered index (and any other index with the column) to reclaim the space. See repro
    below:
    CREATE TABLE myblobbie (id int   NOT NULL PRIMARY KEY,
                            name sysname  NOT NULL,
                            blob varchar(MAX) NOT NULL)
    go
    INSERT myblobbie(id, name, blob)
       SELECT object_id, name, replicate(convert(varchar(MAX), name), 1000)
       FROM   sys.objects
    go
    EXEC sp_spaceused myblobbie
    go
    ALTER TABLE myblobbie DROP COLUMN blob
    go
    EXEC sp_spaceused myblobbie
    go
    ALTER INDEX ALL ON myblobbie REBUILD
    go
    EXEC sp_spaceused myblobbie
    go
    DROP TABLE myblobbie
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Difference in File Adapter Read File as attachment and Use File streaming

    Hi all,
    As part of our POC we created a File adapter using the option Read file as attachment and File streaming we observed below things
    1.When we are taking “Attachment” option in file adapter, Its able to archive, but not supporting to write data to different location(using fileadapter’s write operation.)
    2.when WE are taking “ file streaming “ option in the adapter , Its not able to achive, but it writes data to different location(using fileadapter’s write operation.)
    Can anyone know is this is a correct behaviour . If yes what is the reason .
    Thanks
    Phani

    Hi all,
    As part of our POC we created a File adapter using the option Read file as attachment and File streaming we observed below things
    1.When we are taking “Attachment” option in file adapter, Its able to archive, but not supporting to write data to different location(using fileadapter’s write operation.)
    2.when WE are taking “ file streaming “ option in the adapter , Its not able to achive, but it writes data to different location(using fileadapter’s write operation.)
    Can anyone know is this is a correct behaviour . If yes what is the reason .
    Thanks
    Phani

  • HT1752 My MacBook on startup shows file with question mark ,, what now?

    My Mac shows file with question mark, what now.

    Press the power button down to force a emergency use only hardware shutdown.
    Press and hold the Option/alt key on the built in keyboard, boot the machine.
    If MacintoshHD appears, select it and click the arrow, then in System Preferences > Startup Disk reset that. Done.
    Sometimes a NVRAM reset is required then the above done again.
    Folder with question mark issue
    ..Step by Step to fix your Mac
    If MacintoshHD doesn't appear, or if it boots to gray screen or other issues, then it's more complicated of a fix, but once inside OS X then reset the Startup Disk.
    Gray, Blue or White screen at boot, w/spinner/progress bar
    ..Step by Step to fix your Mac
    You might need this if you don't have a recent backup and your problem is software related, Disk Utiltiy can't fix the drive and recommends you backup, erase and install.
    .Create a data recovery/undelete external boot drive
    If Disk Utility + Hardware Test shows no boot drive, then you have a dead drive or cable, or Mac issue.
    My computer is not working, is my personal data lost?

  • File Streams *creating Files without those pesky line breaks

    Greetings Java Developers,
    Basicly I would like to write a large block of data out to a file without any line breaks and end of line characters that most JAVA Output Streams include with each call to WRITE(); First I am using BYTE Output Streams in JAVA and two end of line bytes are written also!!!
    It may be possible to use a Buffered File Stream with a Large Buffer about a Megabyte or so and FLUSH() the Stream all at once.
    Any ideas or suggestions will be greatly appreaciated!
    -chibi_neko

    I have not had a problem writing bytes to file. The getStream call returns a FileOutputStream. Also note that the curly braces around 'i' really are square braces but I used them because square braces around I get reformatted in his post.
          * Write bytes to a file.
          @param Data Data to write to a file.
          @param file Destination file.
         public static void write(byte [][] Data, File file)
              try
                   OutputStream out = getStream(file);
                   for(int i = 0 ; i < Data.length ; i++)
                        out.write(Data{i});
                   out.close();
              catch(IOException E)
                   throw new Error(E.getMessage());
              catch(Exception e)
                   throw new Error(e.getMessage());
         }the getStream method
    FileOutputStream fw = new FileOutputStream(file.getPath(),append);

  • File and question mark when starting

    Flashing file and question marl when i start my computer

    There are four general causes of this issue:
    1. The computer's PRAM no longer contains a valid startup disk setting when there aren't any problems with the disk itself. This can be checked for by pressing the Option key and seeing if the drive appears.
    2. The internal drive's directory structure has become damaged. This requires usage of an alternate bootable system to perform the repair.
    3. Critical system files have been deleted. This requires usage of an alternate bootable system to reinstall them.
    4. The internal drive has died or become unplugged. This is the most likely case if the computer took a sharp impact or there are unusual sounds coming from its location.
    (103563)

  • .AVI file format question

    Upgrading from CS2 to Photoshop CS5
    I found out after the fact that in order to edit video you need CS5 Extended.
    So, I then went and returned regular and upgraded to Photoshop CS5 extended.
    (See my other thread for details, but installing the 12.01 patch is not an option at this time.)
    Try to use file open to open a .AVI file from one of my cameras and get a message of "unrecognized file format".
    Was able to import the 7 second video into layers.
    Checked support issues, and installed Quicktime 7.6.8
    Also, due to 12.01 issues, reinstalled Photoshop CS5 Extended AFTER upgraded Quicktime to 7.6.8
    Machine specs:  Toshiba Satellite P30  Intel Pentium 4 CPU 3.60 GHZ (Hyperthreading Dual Core) 2GB RAM ATI Mobility Radeon X600 Win XP Professional SP3 About 12 GB disk space available at install time.
    Note that Quicktime will open the .AVI file in question with no problems, as well as Roxio software (trying to get rid of that with CS5)

    I talked to support via phone and it appears the the problem is in installation.  The install of CS5 extended did not take over the regular install.  So, I need to start by completely uninstalling AGAIN and installed extended from scratch AGAIN.
    I did try the program mention GSPOT as well.  It says AVI codecs are installed on the machine inquestion.  I will get more informaiton tonight afte rI do the re-install and see what happens.

  • File Serializable question

    hi,
    i know i've seen plenty of posts asking how to transfer files, my question is why doesn't simplying sending a file object from the client to the server work, file just implement Serializable? is it because the contents don't travel with the object? i'm pretty sure the object will go across, via socket programming or rmi, but why not the contents, or will they?
    Thank you.

    Because the file object, to the best of my knowledge,
    does not hold the contents, it just contains
    information about the file, such as its path.Very true. I never thought about it in this depth before, but the [url http://java.sun.com/j2se/1.4.1/docs/api/java/io/File.html]API says:
    "An abstract representation of file and directory pathnames."
    That's all it is, a representation, not an actualy file.
    Cheers,
    Radish21

Maybe you are looking for

  • How to use loop functionality in XI

    Hi, I am working with Idoc to file scenario. And my requirement in some of the fields are as follow. IF E1IDB02 BA-FIIKWAER = CNY      then MID(E1EDKA1 BE-NAME1,12,11) IF E1IDB02 BA-FIIKWAER <> CNY and LEN(E1EDKA1 BE-NAME1)<=35     then MID(E1EDKA1 B

  • TS4118 how to sync calendar/contacts with imac, ipad, & iphone

    I am having issues syncing with all of my products and would love some assistance, please.  I have the new ipad and the iphone 5.  I also have an imac running Mac OS X (version 10.6.8).  I can sync the ipad and iphone 5 with icloud but I end up with

  • 2011 i5 MacBook Air unable to sleep with lid open after upgrading to 10.7.1

    Hi,    After upgrading to 10.7.1 I noticed my 2011 i5 MacBook Air being unresponsive to wake events.  Per instructions I saw from other posts I pointed the Startup Disk to my main partition.  Shortly after (though I'm sure unrelated to Startup Disk)

  • Converting date problem

    hi, I have a text filed.the textfield must take date value.for that I used the following code. <h:inputText id="joiningdate" binding="#{Employee.field}" value="#{Employee.joiningDate}" valueChangeListener="#{Employee.dateChanged}" > <f:convertDateTim

  • Adobe Acrobat - Create a Link from a Polygon

    I have a PDF file that displays a map of a city divided into polygons. I would like to allow viewers to mouse over and click a polygon which would then open a more detailed PDF of just that area. Adobe Acrobat Professional 7.0 has the 'rectangle link