Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home Answers Viewqa Java-Beginners tokenizing a java file

Have Programming Question? Ask it here!

tokenizing a java file
1 Answer(s)      3 years and 3 months ago
Posted in : Java Beginners

Hi i am new to java and i am trying to build lexecal analyser for java code , I am in the beginning want to read the file then tokanize it, so i wrote this code that read line from the buufer , put it in string then put the tokens into array of string ,but after run the code it gives" error:null" plz kindly could any of you tell me what is wrong in it . also i want to use the tokenizer class but i don't know how to use it,realy i would be thankful if you kindly help me in this . print("import*; import java.util.Scanner;

class FileRead{

@SuppressWarnings("null") public static void main(String args[]) {


FileInputStream fstream = new FileInputStream("");
new BufferedReader(new InputStreamReader(fstream));

    BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
String strLine = " ";
String tokens[] = null ;
int i=0;
//Read File Line By Line

Scanner input = new Scanner( strLine );
while ( (strLine =br.readLine()) != null)   {
    //StringTokenizer st =new StringTokenizer(fstream);
    //System.out.println (strLine);

while(( tokens[i]!= null){

  System.out.println (tokens[i]);


//Close the input stream

// in.close(); }catch (Exception e){//Catch exception if any System.err.println("Error: " + e.getMessage());

} }}


View Answers

May 30, 2011 at 12:55 PM

import java.util.*;

class FileRead{

 public static void main(String args[]) {


File f=new File("");
BufferedReader br = new BufferedReader(new FileReader(f));
String strLine = " ";
String filedata="";
while ( (strLine =br.readLine()) != null)   {
filedata+=strLine+" ";
StringTokenizer stk=new StringTokenizer(filedata);
       String token=stk.nextToken();
 }catch (Exception e){
     System.err.println("Error: " + e.getMessage());


Related Tutorials/Questions & Answers:
tokenizing a java file
tokenizing a java file    Hi i am new to java and i am trying to build lexecal analyser for java code , I am in the beginning want to read the file... = " "; String tokens[] = null ; int i=0; //Read File Line By Line Scanner input
Tokenizing Delimiters
Java: Tokenizing Delimiters Purpose When tokenizing a string... from the String d Example: Tokenizing an expression Here is an example... run Java 2 applets correctly yet, so it's doubtful that you can see it working
String file in to word file in java
String file in to word file in java  How to convert a String format notepad file into Ms word file in java
String file in to word file in java
String file in to word file in java  how to convert a String format word file into Ms Word file using java? please can anyone of you help me
calling a java file in java
calling a java file in java  how to call a another java file in java
file in java - Java Beginners
file in java  I want to count the number of white line and comment line in a file (.sql) with java if you have an example thank you in advance
Java file class
Java file class  What is the purpose of the File class
Convert Class File to .java File - Java Beginners
Convert Class File to .java File  Sir, How To Convert .class file to .java File. Please Help me  Use cavaj software ,which is freeware, to convert .class to .java  Use jd-gui to convert ur .class to .java
Java code to convert pdf file to word file
Java code to convert pdf file to word file  How to convert pdf file to word file using Java
Java File - Java Beginners
Java File  Hi Friend, Thank you for the support I got previously... Anyone please send me the Java Code for scanning a directory and print.... Output Print the file names and size of the file to the console. Please
java get file permission
java get file permission  How to check the get file permission in Java
Reading a text file in java
in* package for reading and writing to a file in Java. To learn more about reading text file in Java see the tutorial Read File in Java. Thanks...Reading a text file in java  What is the code for Reading a text file
How to write in File in Java
How to write in File in Java  Hi, How to write in File in Java. Please suggest and give example of this program. thanks
java read file
java read file  Hello i need some help... i want to read an MS Excel file in java so how to read that file
Batch file for java application
Batch file for java application  please tell me how to create the batch file for java application(using swings).the application is created with netbeans
java file handling
java file handling  enter string from keyboard and then read a file if this string is present in file then print message already exists else write this string to file
Read file in java
Read file in java  Hi, How to Read file in java? Thanks   Hi, Read complete tutorial with example at Read file in java. Thanks
Reading big file in Java
Reading big file in Java  How to read a big text file in Java program?   Hi, Read the complete tutorial at How to read big file line by line in java? Thanks
File handling in Java
handling in Java? Thanks   Hi, File handling is very important... such as .properties file or xml file. Java programming language also provide very good file handling features in their api. You can read more at File Handling in Java
Java write to file
Java write to file  How to write to a file in Java? Is there any good example code here? Thanks   Hi, Java is one of the best... Handling examples in Java Java Input/Output Examples How to read file in Java
Java class file
Java class file  How do i open a java class file using eclipse
Execute .dll file in java?
Execute .dll file in java?  please anybody give me solution for executing .dll files in java
How to compress a file in Java?
How to compress a file in Java?  How to compress a file in Java through Java code? I want a good example in Java. Thanks   Hi, Check the tutorial Compressing the file into GZIP format. Thanks
Download a file - Java Beginners
Download a file   Hi, I need a java code to download a file from a website and before downloading it should give me an option to browse and select the location to put the file. Thanks in advance
Java lock file or folder.
Java lock file or folder.  Is it possible to create a desktop application to lock or encrypt file or folder in windows by using java code?? if possible can provide some reference?? because i can't find it... thanks
Read from file java
Read from file java  How to Read from file java? What is the best method for a text file having a size of 10GB. Since i have to process the file one line at a time so tell me the very best method. Thank you
Java file byte reader
Java file byte reader  I am looking for an example program in Java for reading the bytes. More specifically I need java file byte reader example code. Thanks   For complete details read the following tutorials: Java
java file handling
java file handling  program to get values from textbox array and the write them to text files
Java I\O file
Java I\O file  What is the difference between the File and RandomAccessFile classes
Java delete file if exists
Java delete file if exists  Hi, Hi how to delete file if exists? I need example code of java delete file if exists. Thanks   Hi... if tempFile exists File fileTemp = new File(tempFile); if (fileTemp.exists
How to write in File in Java
How to write in File in Java  Hi, How to write in File in Java... to write in File of Java Program..., For writing some data in the file we require some class file, objects
Java read binary file
Java read binary file  I want Java read binary file example code... at Reading binary file into byte array in Java. Thanks   Hi, There is many more examples at Java File - Learn how to handle files in Java with Examples
Executale File - Java Beginners
Executale File  Plz tell me how to convert java file into .exe file... the instruction.. Good Luck i don;t know how to create the exe file for java  ... for java but you can create an executable jar file .create a MF file
jar file - Java Beginners
an application packaged as a JAR file (requires the Main-class manifest header)java -jar...jar file  jar file When creating a jar file it requires a manifest file. what is the manifest file, and how to create it. And tell me more about
IO File - Java Beginners
IO File  Write a java program which will read an input file & will produce an output file which will extract errors & warnings. It shall exclude... from the log file. This is the task assigned to me..Please help me
Java upload file to ftp
Java upload file to ftp  Hi, How to uploaded file to a ftp server in Java? Thanks   Hi, It's very easy to write a program in Java.... View complete example at FTP File Upload in Java Thanks
How to Write to file in Java?
How to Write to file in Java?  How to Write to file in Java Program?   Hi, For writing a file in Java, we need some classes from Java.IO package. Mostly we define two types of classes in java file i.e. FileWriter
xml file creation in java
xml file creation in java  how to create xml file in java so that input should not be given from keyboard. and that file should be stored.   Please visit the following links:
File Handling in Java
File Handling in Java  Hi, While opening a file in Java developers... was trying to find some tutorials about handling file in Java on net. I have also seen... of file. Java also cares about the performance of the application. It provides
Java File Management Example
Java File Management Example  Hi, Is there any ready made API in Java for creating and updating data into text file? How a programmer can write code for reading the text file? What is best way to read a text file in Java
java file handling
java file handling  Hi friends, My situation is i have file named "sample.conf" which contains more IP Adressess.Eg: the file contains "IP=" at some lines in the file. what i need to do is. i need to search
copy file - Java Beginners
File("C:\\Answers\\Master.txt"),new File("c:\\java\\Master.txt...copy file  i want to copy file from one folder to another  ... CopyFile{ public void copy(File src, File dst) throws IOException
Playing mp3 file in Java...
Playing mp3 file in Java...  I created frame with play and stop buttons and added separate ActionListener to those buttons but i can't stop the music while playing
Creating dynamic jsp file in java file to include another jsp file
Creating dynamic jsp file in java file to include another jsp file  I am able to create jsp file in java that includes ; table tr td and img tags..... Need to include jsp file in the same content. The below code doesn't help me
file handling - Java Beginners
manner. now write a progam in java and create another file which is having the amount required to purchase each item and at last read the newly created file...file handling  assume two files are there- 1. with the quanity of he
Java Jar File - Java Beginners
Java Jar File  What is a Java JAR file ..and how can i open a .jar file in Java?  Just create a Jar file and Double click on it, it will automatically runs main method in that Jar : to create Project as JAR
Java source file - Java Beginners
, You can use Java Decompiler tools like "Cavaj" to decompile the .class file...Java source file  i create a just now but mistakenly i delete the source file. Now i have only the class file. Is there any chance for me
core java-file
core java-file  hi, i want to create a file name simple.txt using command promt and also i want to insert a 36 numbers in a file using command prompt only and then i want to make that data in the form two data in a bracket lke
file arraival in java - Java Beginners
file arraival in java  A simple java program that runs continuously as a background process and prints out according to a given event based schedule(Arrival of a file in a specified directory) and is exited only through manual
Excel file Handling in Java
Excel file Handling in Java  Hello Sir, I am new to Java, I have Started Java Core by myself. I want to make a project which include 3-4 Excel file...://   Now to create an excel file