Results 1 to 3 of 3
- 09-29-2013, 12:30 PM #1
Member
- Join Date
- Jul 2013
- Posts
- 52
- Rep Power
- 0
reading input from text and convert it to character array?
Assume that there is a file named abc which contains of characters a b c d e ... inside
I need to read from the file and convert it to character array. How to do it?
I have tried several ways but it failed to do it
Java Code:Scanner input = new Scanner("abc.txt"); while(input.hasNext()){ char s = input.next().charAt(0); }
- 09-29-2013, 12:58 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
Re: reading input from text and convert it to character array?
The String class has a toCharArray() method (read its API documentation) ...
kind regards,
JosBuild a wall around Donald Trump; I'll pay for it.
- 09-29-2013, 01:26 PM #3
Member
- Join Date
- Jul 2013
- Posts
- 52
- Rep Power
- 0
Similar Threads
-
Please help reading input from text file...
By kkmoslehpour in forum New To JavaReplies: 11Last Post: 10-26-2012, 04:50 AM -
How to convert array list into character
By suniva in forum New To JavaReplies: 1Last Post: 07-28-2012, 04:49 PM -
Problem reading a text file into a two-dimensional character array
By wvu5004 in forum New To JavaReplies: 5Last Post: 03-12-2011, 02:04 AM -
How to create UPPERCASE formatted text field with mixed character input
By r00tb33r in forum AWT / SwingReplies: 2Last Post: 08-21-2010, 11:53 AM -
reading text character by character
By bugger in forum New To JavaReplies: 2Last Post: 11-09-2007, 09:54 PM
Bookmarks