How to get a list of words and lines in a two dimensional array?

I have a text file of full of sentences and I am trying to get the individual words split up into a two dimensional array in java. The rows of the array correspond to the lines of the text, and the columns are the individual words. Any help would be much appreciated.

-------------Problems Reply------------

You just need a few things:

  • a BufferedReader, which has the method public String readLine() to read a line from the file.
  • the method public String[] split(String regex) from String class that can split a string with specified regular expression and already place single strings in an array.
  • iterate over the file, read a line as long as there are available, split the line, and store all of them in a list
  • convert the list to an array and you are done
Category:java Views:0 Time:2012-03-17

Related post

  • What is unit testing? 2008-08-04

    I saw many questions asking 'how' to unit test in a specific language, but no question asking 'what', 'why', and 'when'. What is it? What does it do for me? Why should I use it? When should I use it (also when not)? What are some common pitfalls and

  • Evidence for sealed class performance benefit 2008-08-05

    I have come across a lot of optimization tips which say that you should mark your classes as sealed to get extra performance benefits. I ran some tests to check the performance differential and found none. Am I doing something wrong? Am I missing the

  • Using a DOS command in Ruby script 2008-08-05

    How do I call shell commands from inside of a Ruby program? How do I then get output from these commands back into Ruby? --------------Solutions------------- This explanation is based on this commented Ruby script from a friend of mine. If you want t

  • How to calculate Big O notation from piece of code 2008-08-06

    Most people with a degree in CS will certainly know what Big O stands for. It helps us to measure how (in)efficient an algorithm really is and if you know in what category the problem you are trying to solve lays in you can figure out if it is still

  • DISCUSSION - Uploading and Storing Mass Images 2008-08-06

    So I'm using an app that stores images heavily in the DB. What's your outlook on this? I'm more of a type to store the location in the filesystem, than store it directly in the DB. What do you think are the pros/cons? --------------Solutions---------

  • storing files to a database or just to the local hard-disk? 2008-08-06

    So I'm using an app that stores images heavily in the DB. What's your outlook on this? I'm more of a type to store the location in the filesystem, than store it directly in the DB. What do you think are the pros/cons? --------------Solutions---------

  • How do I retrieve my MySQL username and password? 2008-08-07

    I lost my MySQL username and password. How do I retrieve it? --------------Solutions------------- Stop the MySQL process. Start the MySQL process with the --skip-grant-tables option. Start the MySQL console client with the -u root option. List all th

  • How do I update Ruby Gems from behind a Proxy (ISA-NTLM) 2008-08-07

    Firewall I'm behind is running Microsoft ISA server (NTLM only mode), anyone have success getting their Ruby gems to install/update via Ruby SSPI gem or other method? ... or am I just being lazy? Edit: rubysspi-1.2.4 does not work UPDATE: This also w

  • ruby script/plugin discover RuntimeError 2008-08-07

    Firewall I'm behind is running Microsoft ISA server (NTLM only mode), anyone have success getting their Ruby gems to install/update via Ruby SSPI gem or other method? ... or am I just being lazy? Edit: rubysspi-1.2.4 does not work UPDATE: This also w

  • How do you properly mock an IEnumerable? 2008-08-07

    My latest disaster stumbling through mocking is not grokking that I need to actually push results inside a mock object of IEnumerable<T>. Here's a sample (demonstration only of IEnumerable<T>, not actually good interaction-based testing!)

  • Domain Specific Language resources 2008-08-07

    I was just listening to some older .Net Rocks! episodes, and I found #329 on DSLs to be interesting. My problem is that I can't find any good online resources for people trying to learn this technology. I get the basics of the creating new designers,

  • MAPI and managed code experiences? 2008-08-07

    Using MAPI functions from within managed code is officially unsupported. Apparently, MAPI uses its own memory management and it crashes and burns within managed code (see here and here) All I want to do is launch the default e-mail client with subjec

  • Using Xming X Window Server over a VPN 2008-08-07

    I have the Xming X Window Server installed on a laptop running Windows XP to connect to some UNIX development servers. It works fine when I connect directly to the company network in the office. However, it does not work when I connect to the network

  • Http Auth in a Firefox 3 bookmarklet 2008-08-07

    Im trying to create a bookmarklet for posting del.icio.us bookmarks to a seperate account. I tested it from the command line like: wget -O - --no-check-certificate \ "https://seconduser:[email protected]/v1/posts/add?url=http://seet.dk&

  • What was the tag used for 2008-08-07

    Does anyone remember the XMP tag? What was it used for and why was it deprecated? --------------Solutions------------- Well a quick google search on W3C shows it was for displaying formatted text in HTML 3.2 and earlier and was deprecated and pre pre

  • Video Compression: What is discrete cosine transform? 2008-08-07

    I've implemented an image/video transformation technique called discrete cosine transform. This technique is used in MPEG video encoding. I based my algorithm on the ideas presented at the following URL: http://vsr.informatik.tu-chemnitz.de/~jan/MPEG

  • CSharpCodeProvider Compilation Performance 2008-08-07

    Is CompileAssemblyFromDom faster than CompileAssemblyFromSource? It should be as it presumably bypasses the compiler front-end. --------------Solutions------------- CompileAssemblyFromDom compiles to a .cs file which is then run through the normal C#

  • DVCS Choices - What's good for Windows? 2008-08-07

    So I want to get a project on a distributed version control system, such as mercurial, git, or bazaar. The catch is that I need the Windows support to be good, i.e. no instructions that start off with "install cygwin...". Now I've heard that git's Wi

  • Why should I learn Lisp? 2008-08-07

    I really feel that I should learn Lisp and there are plenty of good resources out there to help me do it. I'm not put off by the complicated syntax, but where in "traditional commercial programming" would I find places it would make sense to use it i

  • MOSS SSP Issue - Failed database logons from deleted SSP 2008-08-07

    We've been having some issues with a SharePoint instance in a test environment. Thankfully this is not production ;) The problems started when the disk with the SQL Server databases and search index ran out of space. Following this, the search servic

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.089 (s). 11 q(s)