Results 21 to 40 of 51
Thread: Writing file input in a matrix
- 01-25-2012, 04:46 PM #21
Member
- Join Date
- Jan 2012
- Posts
- 17
- Rep Power
- 0
- 01-25-2012, 04:48 PM #22
Member
- Join Date
- Jan 2012
- Posts
- 17
- Rep Power
- 0
- 01-25-2012, 04:50 PM #23
Re: Writing file input in a matrix
Time to read the API doc for the Scanner class to see what the choices for constructors are. The Scanner class can be used in many ways.
Java Platform SE 6
- 01-25-2012, 04:52 PM #24
Senior Member
- Join Date
- Jan 2012
- Posts
- 210
- Rep Power
- 2
- 01-25-2012, 04:54 PM #25
Member
- Join Date
- Jan 2012
- Posts
- 17
- Rep Power
- 0
- 01-25-2012, 04:58 PM #26
Member
- Join Date
- Jan 2012
- Posts
- 17
- Rep Power
- 0
- 01-25-2012, 05:00 PM #27
Member
- Join Date
- Jan 2012
- Posts
- 17
- Rep Power
- 0
Re: Writing file input in a matrix
Now that i get the correct height and width, I get another problem, this is my output when I print out my matrix :
Java Code:# ##### ####### ######## # # ############ ## ################ ### B #################### #### A ########### ###############################################
- 01-25-2012, 05:13 PM #28
Moderator
- Join Date
- Apr 2009
- Posts
- 10,459
- Rep Power
- 16
Re: Writing file input in a matrix
It's pretty clear what the OP is doing here.
Indeed they've explained it.
As for your FileInputStream question, I think you are confusing the OP more...it does not "create a new file".
It opens a stream to an existing file. If the file does not exist it throws an exception.
If you can't help it might be an idea to back out.
- 01-25-2012, 05:16 PM #29
Moderator
- Join Date
- Apr 2009
- Posts
- 10,459
- Rep Power
- 16
Re: Writing file input in a matrix
This was going to be my next possibility.
Your Scanner is reading lines, after stripping out the new line character (which maybe 1 or 2 characters depending on the system).
Your buffered reader on the other hand...
Have you thought about using the BufferedReaders readLine() method and then spreading the chars around?
- 01-25-2012, 05:23 PM #30
Senior Member
- Join Date
- Jan 2012
- Posts
- 210
- Rep Power
- 2
- 01-25-2012, 05:28 PM #31
Member
- Join Date
- Jan 2012
- Posts
- 17
- Rep Power
- 0
- 01-25-2012, 06:02 PM #32
Moderator
- Join Date
- Apr 2009
- Posts
- 10,459
- Rep Power
- 16
- 01-25-2012, 06:03 PM #33
Moderator
- Join Date
- Apr 2009
- Posts
- 10,459
- Rep Power
- 16
- 01-25-2012, 06:34 PM #34
Senior Member
- Join Date
- Jan 2012
- Posts
- 210
- Rep Power
- 2
Re: Writing file input in a matrix
No need reacting in the way "back out", cause I'm also trying to learn something, since this is my 3rd week of learning Java.
I made mistake when saying new File instance, cause my point was that FileInputStream can not be created by using "YourFile" as argument, cause it is not valid file path.
What I meant to say is that FileInputStream should be created with new File instance as an argument.
- 01-25-2012, 11:04 PM #35
Re: Writing file input in a matrix
Check the API doc. Why can't you read from a file named: "YourFile"?FileInputStream can not be created by using "YourFile" as argument, cause it is not valid file path.
-
Re: Writing file input in a matrix
- 01-25-2012, 11:10 PM #37
Senior Member
- Join Date
- Jan 2012
- Posts
- 210
- Rep Power
- 2
- 01-25-2012, 11:12 PM #38
Re: Writing file input in a matrix
try it and let us know what happens. Extensions are NOT required
- 01-25-2012, 11:25 PM #39
Senior Member
- Join Date
- Jan 2012
- Posts
- 210
- Rep Power
- 2
- 01-25-2012, 11:29 PM #40
Re: Writing file input in a matrix
Yes I agree that that is a good way to do it. However you are hijacking another OPs thread and potentially confusing him.How is man supposed to learn but not by making mistakes and finding correct answers?
There is no restriction for you to start your own thread with your own questions.
Similar Threads
-
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 -
Reading and Writing the contents of a file to another file
By priyankatxs in forum New To JavaReplies: 9Last Post: 10-20-2009, 10:52 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 -
swapping the contents of the file and writing to another file
By Ms.Ranjan in forum New To JavaReplies: 9Last Post: 07-10-2008, 04:52 PM


5Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks