Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input From a text file

Status
Not open for further replies.

Liam

Programmer
May 4, 2000
3
IE
Hi...<br>I am trying to input from a text file and store the data so it can be encrypted by tripple Des.&nbsp;&nbsp;The i/p in to the tripple des is the key and the data(byte[]) from the disk, I have tried numerous methods and it is wrecking my head.&nbsp;&nbsp;I am very confused by all the different streams.&nbsp;&nbsp;I was wondering could anybody shine some light on the topic...<br>thank you<br>Liam
 
Java is very similar to C in this aspect you first have to make a file input stream then start reading data from it and watch for the eof of the file.<br>//code<br>boolean eof = false;<br>int value;<br>try{<br>FileInputStream inDat = new FileInputStream(&quot;asdf.dat&quot;);<br>while(!eof)<br>{<br>value = inDat.read();<br>System.out.println(value);<br>if (value == -1) eof = true;<br>}<br>inDat.close();<br>}<br>catch(IOException e) {<br>&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&quot;error&quot; + e.toString());<br>}<br><br>the try,catch is to catch any type of error and do something about it.&nbsp;&nbsp;in this case it is IOException, if the filename you put in is not valid or is corrupted some how.<br>from here you can set it to use differn't buffers such as<br>to take in character etc.. as how you will do the encryption part i have never messed with that stuff so i don't know :)<br>hope this helps<br><br> <p>moses<br><a href=mailto:tmoses@iname.com>tmoses@iname.com</a><br><a href= my site</a><br> "We've heard that a million monkeys at a million keyboards could produce the<br>
Complete Works of Shakespeare; now, thanks to the Internet, we know this is<br>
not true." <br>
--Robert Wilensky, University of California <br>
<br>
<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top