DOC PREVIEW
TRINITY CSCI 1320 - Lecture Notes

This preview shows page 1-2-3-4-5 out of 14 pages.

Save
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Files 3 7 2012 Opening Discussion Minute essay comments Would things make more sense without the power outage An Array can be treated as a vector Are there packages for matrix math Scalalab My reactions to the Slate articles Send code when missing an IcP is read as in How was SIGCSE Can Scala do 4 D matrices More More matrices Most common loop Accessing higher dimensional arrays Extra credit on other exam When is the final Why use print instead of println I don t think Japan has an obesity problem The API To get a sense of the different package in Scala it is helpful to look at the API There are still lots of things in the API you won t fully understand That isn t a problem as you aren t expected to get too much from it right now scala io Source Call Source fromFile fileName String to get a Source object that reads from a file There are other methods in the main Source object that we will learn about later The fromFile method technically gives you BufferedSource This is for efficiency Iterators Both Source and BufferedSource are of the type Iterator Char An Iterator has most of the methods you are used to from List and Array However you can only go through it once Fundamentally uses hasNext and next methods getLines This will give you an Iterator String that will go through the file one line at a time instead of a character at a time You will often find this more useful java util Scanner Java Scanner class sometimes easier for input hasNext next hasNextInt nextInt hasNextDouble nextDouble Doesn t produce a Scala collection Needs java io File new Scanner new File fileName Always make a new object from the Java libraries using new Scala typically allows you to leave that off Closing Files Make sure you always close files when you are done using them Source Scanner and pretty much anything else that pulls from a file will have a close method java io PrintWriter To write to files use java io PrintWriter Create with new PrintWriter fileName Has print and println methods just like what you have been using to print to screen Flush To make certain contents have been written to the file use flush Doing close will also flush and you should definitely remember to close all files you are writing when done with them Command Line Arguments In a script the command line arguments are put in args Array String You can do anything with them that you would do with a normal array Examples Print some random numbers to a file A file copy with word replace Minute Essay What questions do you have IcP 5 on Friday note this is moving back a class


View Full Document

TRINITY CSCI 1320 - Lecture Notes

Documents in this Course
Functions

Functions

10 pages

Functions

Functions

10 pages

Graphics

Graphics

10 pages

Graphics

Graphics

11 pages

Loops

Loops

4 pages

Loops

Loops

3 pages

Strings

Strings

9 pages

Functions

Functions

10 pages

Loops

Loops

11 pages

Graphics

Graphics

11 pages

Graphics

Graphics

12 pages

Sorting

Sorting

11 pages

Sorting

Sorting

10 pages

Arrays

Arrays

10 pages

Loops

Loops

18 pages

Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?