Results 1 to 2 of 2
Thread: Writing to .Txt File Logic
- 11-19-2012, 12:03 AM #1
Member
- Join Date
- Oct 2012
- Posts
- 20
- Rep Power
- 0
Writing to .Txt File Logic
Point of this program is to ask the user for 10 items they would want on an island with them, then ask for the price of said item, and write item and price to a .txt file. Right now its doing this as soon as it gets to the second item and you can not enter a second item name only a price:

PHP Code://MakeIslandList.java by Tyler 11/18/2012 import java.io.*; import java.util.*; public class MakeIslandList { public static void main(String[] args) throws IOException { DataOutputStream ostream; Scanner input = new Scanner(System.in); int count = 1; String item; double itemCost; ostream = new DataOutputStream(new FileOutputStream("MakeIslandList.txt")); try { while(count != 11){ System.out.print("Enter your number " + count + " item you would have on an island \n"); item = input.nextLine(); System.out.print("Enter the cost of this item \n"); itemCost = input.nextDouble(); ostream.writeUTF(item); ostream.writeDouble(itemCost); count++;} } catch(IOException e) { System.err.println("Error writing to file"); } finally { ostream.close(); } } }
- 11-19-2012, 02:46 AM #2
Similar Threads
-
Problem with File I/O, writing information to a binary file.
By Trithan in forum New To JavaReplies: 1Last Post: 08-02-2012, 03:01 AM -
Trying to read a file, then writing the info into another file
By bigsonny in forum New To JavaReplies: 14Last Post: 07-15-2011, 05:22 AM -
Im writing to a file and i want to skip lines while writing to a text file.
By Broden_McDonald in forum New To JavaReplies: 1Last Post: 02-27-2010, 01:29 AM -
[SOLVED] how to reading binary file and writing txt file
By tOpach in forum New To JavaReplies: 3Last Post: 05-09-2009, 11:31 PM -
Logic Error: Not Writing To File
By JDCAce in forum Advanced JavaReplies: 6Last Post: 10-21-2008, 02:13 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks