Important ref data types
Download
1 / 8

Important Ref. Data Types - PowerPoint PPT Presentation


  • 65 Views
  • Uploaded on

Important Ref. Data Types. Tokenizers String customers=“tom,dick,harry”; csv-> String s[]. What is a String Tokenizer?. Class that uses a string to create substrings Substrings are tokens. String input =“this is a sample string”; //– Garbage in

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Important Ref. Data Types' - huela


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Important ref data types

Important Ref. Data Types

Tokenizers

String customers=“tom,dick,harry”;

csv-> String s[]


What is a string tokenizer
What is a String Tokenizer?

  • Class that uses a string to create substrings

  • Substrings are tokens.

    • String input =“this is a sample string”;

      //– Garbage in

    • String output[] = {“this”, “is”, “a”, “sample”, “string”}; // - Garbage out!

    • The output is a tokenized version of the input.


Where is stringtokenizer
Where is StringTokenizer?

  • in the package java.util.

    • import java.util.StringTokenizer;


How do you make a stringtokenizer
How do you make a StringTokenizer?

StringTokenizer st = new StringTokenizer(“1,2,3,4 5\” –6”, “,\” ”);



How can i use the stringtokenizer
How can I use the StringTokenizer?

while (st.hasMoreTokens()) {

System.out.println(st.nextToken());

}

String s = st.nextToken();

for (int i=0; s != null; s = st.nextToken()) {

System.out.println(s);

}


How do i read a csv file
How do I read a CSV File?

firstName, LastName, StAddress, City, State, ZIP, ph1, ph2, ph3

One record per line.

String fn = Futil.getFileName();

File f = new File(fn);

FileInputStream fis = new FileInputStream(f);

BufferedReader br = new BufferedReader(fis);


How do i read a csv file1
How do I read a CSV File?...

while ((String s = br.readLine()) != null) {

processALine(s);

}

fis.close();


ad