Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

i need some help working with strings (yea i know, strings lol)

843785Aug 27 2008 — edited Aug 27 2008
String[] courseObjects = new String[3];
		File courses = new File("courses.txt");
		BufferedReader in = null;

		try
		{
			in = new BufferedReader(
			new FileReader(courses));

			for (int i = 0; i < courseObjects.length; i++)
			{
			    courseObjects[i] = in.readLine();
			}

			in.close();
		}
			catch(IOException ioe)
			{
				System.out.println(ioe);
			}

			int n = -1;

		String[] classCode = new String[3];

		for(int i = 0; i < courseObjects.length; i++)
		{
			String classCode[i] = courseObjects.substring(0, 6);
}
the second for loop doesn't seem to be working for me.. i know i'm probably doing something wrong.
basically, i want to get a substring from a string in the courseObjects array and put it into the classCode element.
what am i doing wrong?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 24 2008
Added on Aug 27 2008
9 comments
195 views