WordPress database error: [Server shutdown in progress]
SELECT meta_id FROM wad_postmeta WHERE meta_key = 'post_views_count' AND post_id = 2729


Warning: Error while sending QUERY packet. PID=16579 in /home/webartdev/public_html/blog/wp-includes/wp-db.php on line 2007

Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /home/webartdev/public_html/blog/wp-includes/wp-db.php on line 1612

How to get Details of a File using StreamTokenizer class in Core Java


Notice: wpdb was called incorrectly. wpdb must set a database connection for use with escaping. Please see Debugging in WordPress for more information. (This message was added in version 3.6.0.) in /home/webartdev/public_html/blog/wp-includes/functions.php on line 4773

In this tutorial how to get details of a file using StreamTokenizer class in Core Java  is shown.

Code:

StreamTokenizerDemo.java

import java.io.*;

public class StreamTokenizerDemo
{
public static void main(String args[]) throws IOException
{
FileReader freader = new FileReader(“Demo.txt”);
StreamTokenizer st = new StreamTokenizer(freader);

double sum=0;
int numWords=0,numChars=0;

while(st.nextToken() != st.TT_EOF)
{
if(st.ttype == StreamTokenizer.TT_NUMBER)
{
sum+=st.nval;
}
else if(st.ttype == StreamTokenizer.TT_WORD)
{
numWords++;
numChars+=st.sval.length();
}
}

System.out.println(“Sum of total number in the file: “+sum);
System.out.println(“Total words in the file: “+numWords);
System.out.println(“Number of characters available in words: “+numChars);
}
}

Add a Comment

Your email address will not be published. Required fields are marked *