The Artima Developer Community
Sponsored Link

Java Answers Forum
Why does it say Type Vector not found????

2 replies on 1 page. Most recent reply: Jul 13, 2002 9:03 PM by Leslie Jo

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Leslie Jo

Posts: 22
Nickname: leeloo
Registered: Jul, 2002

Why does it say Type Vector not found???? Posted: Jul 13, 2002 7:12 PM
Reply to this message Reply
Advertisement
can anyone see the problem?? below is part of my code:


// The "Utility" class.
import java.io.*;
import java.util.Vector.*;
public class Utility
{

private Utility ()
{
}


/*
* This method reads a text file into an Vector.
* Each element in the vector contains one line from the text file.
*
* parameter filename is the name of the text file to be read.
* returns the vector where each element contains one line from the text file.
*
*/

private static Vector readStringToVector (String filename) throws IOException
{
int n = filename.length ();
Vector V = new Vector (n);
BufferedReader inputStream = new BufferedReader (new FileReader (filename));
String strRead;
while ((strRead = inputStream.readLine ()) != null)
{
V.addElement (strRead);
}
inputStream.close ();
return V;
} // end readStringToVector


/* Converts the vector into a string
*
* returns the array where each element contains one line from the text file
*
*/

public static String [] readFileToArray (String fileName) throws IOException
{
Vector V = readStringToVector (fileName);
String [] anArray = new String [V.size ()];
V.copyInto (anArray);
return anArray;
}


/*
* Accepts an array of strings and write the contents to a text file.
* There is one array element per line in the text file.
*
* parameter filename is the name of the text file to write.
* parameter anArray is the array of String objects to be written out.
*
*/

private static void writeArrayToFile (String [] anArray, String filename) throws IOException
{
PrintWriter dataOut = new PrintWriter (new FileOutputStream (filename));
int i;
for (i = 0 ; i < anArray.length ; i++)
{
dataOut.println (anArray );
}
dataOut.close ();
}


Singh M.

Posts: 154
Nickname: ms
Registered: Mar, 2002

Re: Why does it say Type Vector not found???? Posted: Jul 13, 2002 8:34 PM
Reply to this message Reply
change import java.util.Vector.*;
to import java.util.Vector;

Leslie Jo

Posts: 22
Nickname: leeloo
Registered: Jul, 2002

Re: Why does it say Type Vector not found???? Posted: Jul 13, 2002 9:03 PM
Reply to this message Reply
THANKS

Flat View: This topic has 2 replies on 1 page
Topic: How do I change editable JComboBox editable area????? Previous Topic   Next Topic Topic: Need help with arrays and strings

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use