Blankets_McGee Blankets_McGee - 1 month ago 21
Java Question

Data Mining Strings

Hey guys I was wondering if I could get some help with something. I have a java class Text.java which just contains a severly long string (it's text from a website but stored in u006e values and such) I am creating a data mining class and was just wondering how to reference the string so that i can test things like the length and count refrences to numbers and stuff like that? the actual class is Text.java and the actual code is:

public class Text
{
/**
* A very long String, containing text from a web site.
*/
public static final String TEXT;

static
{
TEXT = //this is where the extremely long string is composed of u006c/u006e and so on


I have tried

text.length()
Text.length()
TEXT.length()


i am fairly new to Java so i might not be going about it correctly but here is just the start of my datamining class

public class DataMiner
{
/**
* Main Method, or main point of entry in the Java application.
*
* @param args not used
*/
public static void main(String[] args)
{
System.out.printf("The total length of input lines are: ", Text.length());
}
}


here i was just looking to tell me how ling the lines of input are within the other Text.java class. Any help is appreciated.

Answer

For a quick fix try this

System.out.printf("The total length of input lines are: %d \n", Text.length());

However better would be to create a method on Text called length that returns TEXT.length() or simply change to Text.TEXT.length() - Personally I would use the first choice and have TEXT as a private field