diff --git a/.gitignore b/.gitignore index 64b61e98..103c549c 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ Temporary Items .apdisk *.class +failures diff --git a/README.md b/README.md index cd9979fb..12174892 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ for Java 8 [Click here](https://github.com/BruceEckel/TIJ4-Refreshed-Examples/archive/master.zip) to download the zip file. Unzip the file into a directory of your choice. ## Build the Examples ## -1. Install the latest version of Java 8 (JDK8). +1. Install the latest version of Java 8 (JDK8). (Use 32-bit version on Windows). 1. Install Apache Ant. Follow the instructions [here](https://ant.apache.org/manual/install.html#getting). diff --git a/access/build.xml b/access/build.xml index 200e456c..dc317f66 100644 --- a/access/build.xml +++ b/access/build.xml @@ -21,7 +21,7 @@ - @@ -30,7 +30,7 @@ - @@ -44,7 +44,7 @@ name="build"> - diff --git a/annotations/build.xml b/annotations/build.xml index ce260394..536420f4 100644 --- a/annotations/build.xml +++ b/annotations/build.xml @@ -21,7 +21,7 @@ - @@ -30,7 +30,7 @@ - @@ -44,7 +44,7 @@ name="build"> - @@ -153,7 +153,7 @@ fork="true"/> - + - - + diff --git a/arrays/build.xml b/arrays/build.xml index 84f6a599..3bc5c848 100644 --- a/arrays/build.xml +++ b/arrays/build.xml @@ -21,7 +21,7 @@ - @@ -35,7 +35,7 @@ name="build"> - diff --git a/bangbean/BangBean.java b/bangbean/BangBean.java deleted file mode 100644 index e0993c4c..00000000 --- a/bangbean/BangBean.java +++ /dev/null @@ -1,81 +0,0 @@ -//: bangbean/BangBean.java -// A graphical Bean. -package bangbean; -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; -import java.io.*; -import java.util.*; - -public class -BangBean extends JPanel implements Serializable { - private int xm, ym; - private int cSize = 20; // Circle size - private String text = "Bang!"; - private int fontSize = 48; - private Color tColor = Color.RED; - private ActionListener actionListener; - public BangBean() { - addMouseListener(new ML()); - addMouseMotionListener(new MML()); - } - public int getCircleSize() { return cSize; } - public void setCircleSize(int newSize) { - cSize = newSize; - } - public String getBangText() { return text; } - public void setBangText(String newText) { - text = newText; - } - public int getFontSize() { return fontSize; } - public void setFontSize(int newSize) { - fontSize = newSize; - } - public Color getTextColor() { return tColor; } - public void setTextColor(Color newColor) { - tColor = newColor; - } - public void paintComponent(Graphics g) { - super.paintComponent(g); - g.setColor(Color.BLACK); - g.drawOval(xm - cSize/2, ym - cSize/2, cSize, cSize); - } - // This is a unicast listener, which is - // the simplest form of listener management: - public void addActionListener(ActionListener l) - throws TooManyListenersException { - if(actionListener != null) - throw new TooManyListenersException(); - actionListener = l; - } - public void removeActionListener(ActionListener l) { - actionListener = null; - } - class ML extends MouseAdapter { - public void mousePressed(MouseEvent e) { - Graphics g = getGraphics(); - g.setColor(tColor); - g.setFont( - new Font("TimesRoman", Font.BOLD, fontSize)); - int width = g.getFontMetrics().stringWidth(text); - g.drawString(text, (getSize().width - width) /2, - getSize().height/2); - g.dispose(); - // Call the listener's method: - if(actionListener != null) - actionListener.actionPerformed( - new ActionEvent(BangBean.this, - ActionEvent.ACTION_PERFORMED, null)); - } - } - class MML extends MouseMotionAdapter { - public void mouseMoved(MouseEvent e) { - xm = e.getX(); - ym = e.getY(); - repaint(); - } - } - public Dimension getPreferredSize() { - return new Dimension(200, 200); - } -} ///:~ diff --git a/bangbean/BangBeanTest.java b/bangbean/BangBeanTest.java deleted file mode 100644 index 9a72d407..00000000 --- a/bangbean/BangBeanTest.java +++ /dev/null @@ -1,32 +0,0 @@ -//: bangbean/BangBeanTest.java -// {Timeout: 5} Abort after 5 seconds when testing -package bangbean; -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import static net.mindview.util.SwingConsole.*; - -public class BangBeanTest extends JFrame { - private JTextField txt = new JTextField(20); - // During testing, report actions: - class BBL implements ActionListener { - private int count = 0; - public void actionPerformed(ActionEvent e) { - txt.setText("BangBean action "+ count++); - } - } - public BangBeanTest() { - BangBean bb = new BangBean(); - try { - bb.addActionListener(new BBL()); - } catch(TooManyListenersException e) { - txt.setText("Too many listeners"); - } - add(bb); - add(BorderLayout.SOUTH, txt); - } - public static void main(String[] args) { - run(new BangBeanTest(), 400, 500); - } -} ///:~ diff --git a/bangbean/build.xml b/bangbean/build.xml deleted file mode 100644 index c755b0de..00000000 --- a/bangbean/build.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - build.xml for the source code for the bangbean chapter of - Thinking in Java, 4th Edition (Refreshed) by Bruce Eckel - Source code available at http://www.MindView.net - See copyright notice in CopyRight.txt - - Ant available from: http://ant.apache.org/ - - To see options, type: ant -p - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build.xml b/build.xml index 7d1facc2..ebb9e336 100644 --- a/build.xml +++ b/build.xml @@ -41,8 +41,6 @@ annotations/build.xml concurrency/build.xml gui/build.xml - frogbean/build.xml - bangbean/build.xml swt/build.xml "/> diff --git a/concurrency/build.xml b/concurrency/build.xml index 0ef95ef2..d5ab7973 100644 --- a/concurrency/build.xml +++ b/concurrency/build.xml @@ -21,7 +21,7 @@ - @@ -30,7 +30,7 @@ - @@ -44,7 +44,7 @@ name="build"> - diff --git a/containers/build.xml b/containers/build.xml index 6d9a7a30..a3df65e5 100644 --- a/containers/build.xml +++ b/containers/build.xml @@ -21,7 +21,7 @@ - @@ -30,7 +30,7 @@ - @@ -39,7 +39,7 @@ - @@ -53,7 +53,7 @@ name="build"> - diff --git a/control/build.xml b/control/build.xml index 97818a6e..231f4251 100644 --- a/control/build.xml +++ b/control/build.xml @@ -21,7 +21,7 @@ - @@ -35,7 +35,7 @@ name="build"> - diff --git a/enumerated/build.xml b/enumerated/build.xml index 83cf3d30..7d326794 100644 --- a/enumerated/build.xml +++ b/enumerated/build.xml @@ -21,7 +21,7 @@ - @@ -35,7 +35,7 @@ name="build"> - diff --git a/exceptions/build.xml b/exceptions/build.xml index 126a7500..25030542 100644 --- a/exceptions/build.xml +++ b/exceptions/build.xml @@ -21,7 +21,7 @@ - @@ -35,7 +35,7 @@ name="build"> - diff --git a/frogbean/Frog.java b/frogbean/Frog.java deleted file mode 100644 index 76083f00..00000000 --- a/frogbean/Frog.java +++ /dev/null @@ -1,44 +0,0 @@ -//: frogbean/Frog.java -// A trivial JavaBean. -package frogbean; -import java.awt.*; -import java.awt.event.*; - -class Spots {} - -public class Frog { - private int jumps; - private Color color; - private Spots spots; - private boolean jmpr; - public int getJumps() { return jumps; } - public void setJumps(int newJumps) { - jumps = newJumps; - } - public Color getColor() { return color; } - public void setColor(Color newColor) { - color = newColor; - } - public Spots getSpots() { return spots; } - public void setSpots(Spots newSpots) { - spots = newSpots; - } - public boolean isJumper() { return jmpr; } - public void setJumper(boolean j) { jmpr = j; } - public void addActionListener(ActionListener l) { - //... - } - public void removeActionListener(ActionListener l) { - // ... - } - public void addKeyListener(KeyListener l) { - // ... - } - public void removeKeyListener(KeyListener l) { - // ... - } - // An "ordinary" public method: - public void croak() { - System.out.println("Ribbet!"); - } -} ///:~ diff --git a/frogbean/build.xml b/frogbean/build.xml deleted file mode 100644 index ea5810fa..00000000 --- a/frogbean/build.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - build.xml for the source code for the frogbean chapter of - Thinking in Java, 4th Edition (Refreshed) by Bruce Eckel - Source code available at http://www.MindView.net - See copyright notice in CopyRight.txt - - Ant available from: http://ant.apache.org/ - - To see options, type: ant -p - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/generics/build.xml b/generics/build.xml index d10b9429..af94d5b7 100644 --- a/generics/build.xml +++ b/generics/build.xml @@ -21,7 +21,7 @@ - @@ -30,7 +30,7 @@ - @@ -39,7 +39,7 @@ - @@ -53,7 +53,7 @@ name="build"> - actionListeners = - new ArrayList(); - public BangBean2() { - addMouseListener(new ML()); - addMouseMotionListener(new MM()); - } - public synchronized int getCircleSize() { return cSize; } - public synchronized void setCircleSize(int newSize) { - cSize = newSize; - } - public synchronized String getBangText() { return text; } - public synchronized void setBangText(String newText) { - text = newText; - } - public synchronized int getFontSize(){ return fontSize; } - public synchronized void setFontSize(int newSize) { - fontSize = newSize; - } - public synchronized Color getTextColor(){ return tColor;} - public synchronized void setTextColor(Color newColor) { - tColor = newColor; - } - public void paintComponent(Graphics g) { - super.paintComponent(g); - g.setColor(Color.BLACK); - g.drawOval(xm - cSize/2, ym - cSize/2, cSize, cSize); - } - // This is a multicast listener, which is more typically - // used than the unicast approach taken in BangBean.java: - public synchronized void - addActionListener(ActionListener l) { - actionListeners.add(l); - } - public synchronized void - removeActionListener(ActionListener l) { - actionListeners.remove(l); - } - // Notice this isn't synchronized: - public void notifyListeners() { - ActionEvent a = new ActionEvent(BangBean2.this, - ActionEvent.ACTION_PERFORMED, null); - ArrayList lv = null; - // Make a shallow copy of the List in case - // someone adds a listener while we're - // calling listeners: - synchronized(this) { - lv = new ArrayList(actionListeners); - } - // Call all the listener methods: - for(ActionListener al : lv) - al.actionPerformed(a); - } - class ML extends MouseAdapter { - public void mousePressed(MouseEvent e) { - Graphics g = getGraphics(); - g.setColor(tColor); - g.setFont( - new Font("TimesRoman", Font.BOLD, fontSize)); - int width = g.getFontMetrics().stringWidth(text); - g.drawString(text, (getSize().width - width) /2, - getSize().height/2); - g.dispose(); - notifyListeners(); - } - } - class MM extends MouseMotionAdapter { - public void mouseMoved(MouseEvent e) { - xm = e.getX(); - ym = e.getY(); - repaint(); - } - } - public static void main(String[] args) { - BangBean2 bb2 = new BangBean2(); - bb2.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - System.out.println("ActionEvent" + e); - } - }); - bb2.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - System.out.println("BangBean2 action"); - } - }); - bb2.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - System.out.println("More action"); - } - }); - JFrame frame = new JFrame(); - frame.add(bb2); - run(frame, 300, 300); - } -} ///:~ diff --git a/gui/BeanDumper.java b/gui/BeanDumper.java deleted file mode 100644 index fc7ec95e..00000000 --- a/gui/BeanDumper.java +++ /dev/null @@ -1,85 +0,0 @@ -//: gui/BeanDumper.java -// Introspecting a Bean. -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; -import java.beans.*; -import java.lang.reflect.*; -import static net.mindview.util.SwingConsole.*; - -public class BeanDumper extends JFrame { - private JTextField query = new JTextField(20); - private JTextArea results = new JTextArea(); - public void print(String s) { results.append(s + "\n"); } - public void dump(Class bean) { - results.setText(""); - BeanInfo bi = null; - try { - bi = Introspector.getBeanInfo(bean, Object.class); - } catch(IntrospectionException e) { - print("Couldn't introspect " + bean.getName()); - return; - } - for(PropertyDescriptor d: bi.getPropertyDescriptors()){ - Class p = d.getPropertyType(); - if(p == null) continue; - print("Property type:\n " + p.getName() + - "Property name:\n " + d.getName()); - Method readMethod = d.getReadMethod(); - if(readMethod != null) - print("Read method:\n " + readMethod); - Method writeMethod = d.getWriteMethod(); - if(writeMethod != null) - print("Write method:\n " + writeMethod); - print("===================="); - } - print("Public methods:"); - for(MethodDescriptor m : bi.getMethodDescriptors()) - print(m.getMethod().toString()); - print("======================"); - print("Event support:"); - for(EventSetDescriptor e: bi.getEventSetDescriptors()){ - print("Listener type:\n " + - e.getListenerType().getName()); - for(Method lm : e.getListenerMethods()) - print("Listener method:\n " + lm.getName()); - for(MethodDescriptor lmd : - e.getListenerMethodDescriptors() ) - print("Method descriptor:\n " + lmd.getMethod()); - Method addListener= e.getAddListenerMethod(); - print("Add Listener Method:\n " + addListener); - Method removeListener = e.getRemoveListenerMethod(); - print("Remove Listener Method:\n "+ removeListener); - print("===================="); - } - } - class Dumper implements ActionListener { - public void actionPerformed(ActionEvent e) { - String name = query.getText(); - Class c = null; - try { - c = Class.forName(name); - } catch(ClassNotFoundException ex) { - results.setText("Couldn't find " + name); - return; - } - dump(c); - } - } - public BeanDumper() { - JPanel p = new JPanel(); - p.setLayout(new FlowLayout()); - p.add(new JLabel("Qualified bean name:")); - p.add(query); - add(BorderLayout.NORTH, p); - add(new JScrollPane(results)); - Dumper dmpr = new Dumper(); - query.addActionListener(dmpr); - query.setText("frogbean.Frog"); - // Force evaluation - dmpr.actionPerformed(new ActionEvent(dmpr, 0, "")); - } - public static void main(String[] args) { - run(new BeanDumper(), 600, 500); - } -} ///:~ diff --git a/gui/build.xml b/gui/build.xml index ceeee506..3de750c9 100644 --- a/gui/build.xml +++ b/gui/build.xml @@ -20,12 +20,8 @@ - - - @@ -38,11 +34,8 @@ description="Build all classes in this directory" name="build"> - - @@ -52,28 +45,6 @@ - - - - - - - - - - - - - - - - - @@ -574,7 +532,6 @@ - diff --git a/gui/flex/Song.java b/gui/flex/Song.java deleted file mode 100644 index eb1b9d27..00000000 --- a/gui/flex/Song.java +++ /dev/null @@ -1,35 +0,0 @@ -//: gui/flex/Song.java -package gui.flex; - -public class Song implements java.io.Serializable { - private String name; - private String artist; - private String album; - private String albumImageUrl; - private String songMediaUrl; - public Song() {} - public Song(String name, String artist, String album, - String albumImageUrl, String songMediaUrl) { - this.name = name; - this.artist = artist; - this.album = album; - this.albumImageUrl = albumImageUrl; - this.songMediaUrl = songMediaUrl; - } - public void setAlbum(String album) { this.album = album;} - public String getAlbum() { return album; } - public void setAlbumImageUrl(String albumImageUrl) { - this.albumImageUrl = albumImageUrl; - } - public String getAlbumImageUrl() { return albumImageUrl;} - public void setArtist(String artist) { - this.artist = artist; - } - public String getArtist() { return artist; } - public void setName(String name) { this.name = name; } - public String getName() { return name; } - public void setSongMediaUrl(String songMediaUrl) { - this.songMediaUrl = songMediaUrl; - } - public String getSongMediaUrl() { return songMediaUrl; } -} ///:~ diff --git a/gui/flex/SongService.java b/gui/flex/SongService.java deleted file mode 100644 index 530b3f44..00000000 --- a/gui/flex/SongService.java +++ /dev/null @@ -1,22 +0,0 @@ -//: gui/flex/SongService.java -package gui.flex; -import java.util.*; - -public class SongService { - private List songs = new ArrayList(); - public SongService() { fillTestData(); } - public List getSongs() { return songs; } - public void addSong(Song song) { songs.add(song); } - public void removeSong(Song song) { songs.remove(song); } - private void fillTestData() { - addSong(new Song("Chocolate", "Snow Patrol", - "Final Straw", "sp-final-straw.jpg", - "chocolate.mp3")); - addSong(new Song("Concerto No. 2 in E", "Hilary Hahn", - "Bach: Violin Concertos", "hahn.jpg", - "bachviolin2.mp3")); - addSong(new Song("'Round Midnight", "Wes Montgomery", - "The Artistry of Wes Montgomery", - "wesmontgomery.jpg", "roundmidnight.mp3")); - } -} ///:~ diff --git a/gui/flex/build-command.txt b/gui/flex/build-command.txt deleted file mode 100644 index 48636f8b..00000000 --- a/gui/flex/build-command.txt +++ /dev/null @@ -1 +0,0 @@ -mxmlc -flexlib C:/"Program Files"/Macromedia/Flex/jrun4/servers/default/flex/WEB-INF/flex songs.mxml diff --git a/gui/flex/helloflex1.mxml b/gui/flex/helloflex1.mxml deleted file mode 100644 index cf504642..00000000 --- a/gui/flex/helloflex1.mxml +++ /dev/null @@ -1,6 +0,0 @@ - - - - diff --git a/gui/flex/helloflex2.mxml b/gui/flex/helloflex2.mxml deleted file mode 100644 index 6bd508e3..00000000 --- a/gui/flex/helloflex2.mxml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - diff --git a/gui/flex/songScript.as b/gui/flex/songScript.as deleted file mode 100644 index 2e194861..00000000 --- a/gui/flex/songScript.as +++ /dev/null @@ -1,22 +0,0 @@ -//: gui/flex/songScript.as -function getSongs() { - songService.getSongs(); -} - -function selectSong(event) { - var song = songGrid.getItemAt(event.itemIndex); - showSongInfo(song); -} - -function showSongInfo(song) { - songInfo.text = song.name + newline; - songInfo.text += song.artist + newline; - songInfo.text += song.album + newline; - albumImage.source = song.albumImageUrl; - songPlayer.contentPath = song.songMediaUrl; - songPlayer.visible = true; -} - -function onSongs(songs) { - songGrid.dataProvider = songs; -} ///:~ diff --git a/gui/flex/songStyles.css b/gui/flex/songStyles.css deleted file mode 100644 index 22fb66d6..00000000 --- a/gui/flex/songStyles.css +++ /dev/null @@ -1,11 +0,0 @@ -.headerText { - font-family: Arial, "_sans"; - font-size: 16; - font-weight: bold; -} - -.boldText { - font-family: Arial, "_sans"; - font-size: 11; - font-weight: bold; -} diff --git a/gui/flex/songs.mxml b/gui/flex/songs.mxml deleted file mode 100644 index be2d0475..00000000 --- a/gui/flex/songs.mxml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gui/jnlp/JnlpFileChooser.java b/gui/jnlp/JnlpFileChooser.java deleted file mode 100644 index 0fbd0265..00000000 --- a/gui/jnlp/JnlpFileChooser.java +++ /dev/null @@ -1,95 +0,0 @@ -//: gui/jnlp/JnlpFileChooser.java -// Opening files on a local machine with JNLP. -// {Requires: javax.jnlp.FileOpenService; -// You must have javaws.jar in your classpath} -// To create the jnlpfilechooser.jar file, do this: -// cd .. -// cd .. -// jar cvf gui/jnlp/jnlpfilechooser.jar gui/jnlp/*.class -package gui.jnlp; -import javax.jnlp.*; -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; -import java.io.*; - -public class JnlpFileChooser extends JFrame { - private JTextField fileName = new JTextField(); - private JButton - open = new JButton("Open"), - save = new JButton("Save"); - private JEditorPane ep = new JEditorPane(); - private JScrollPane jsp = new JScrollPane(); - private FileContents fileContents; - public JnlpFileChooser() { - JPanel p = new JPanel(); - open.addActionListener(new OpenL()); - p.add(open); - save.addActionListener(new SaveL()); - p.add(save); - jsp.getViewport().add(ep); - add(jsp, BorderLayout.CENTER); - add(p, BorderLayout.SOUTH); - fileName.setEditable(false); - p = new JPanel(); - p.setLayout(new GridLayout(2,1)); - p.add(fileName); - add(p, BorderLayout.NORTH); - ep.setContentType("text"); - save.setEnabled(false); - } - class OpenL implements ActionListener { - public void actionPerformed(ActionEvent e) { - FileOpenService fs = null; - try { - fs = (FileOpenService)ServiceManager.lookup( - "javax.jnlp.FileOpenService"); - } catch(UnavailableServiceException use) { - throw new RuntimeException(use); - } - if(fs != null) { - try { - fileContents = fs.openFileDialog(".", - new String[]{"txt", "*"}); - if(fileContents == null) - return; - fileName.setText(fileContents.getName()); - ep.read(fileContents.getInputStream(), null); - } catch(Exception exc) { - throw new RuntimeException(exc); - } - save.setEnabled(true); - } - } - } - class SaveL implements ActionListener { - public void actionPerformed(ActionEvent e) { - FileSaveService fs = null; - try { - fs = (FileSaveService)ServiceManager.lookup( - "javax.jnlp.FileSaveService"); - } catch(UnavailableServiceException use) { - throw new RuntimeException(use); - } - if(fs != null) { - try { - fileContents = fs.saveFileDialog(".", - new String[]{"txt"}, - new ByteArrayInputStream( - ep.getText().getBytes()), - fileContents.getName()); - if(fileContents == null) - return; - fileName.setText(fileContents.getName()); - } catch(Exception exc) { - throw new RuntimeException(exc); - } - } - } - } - public static void main(String[] args) { - JnlpFileChooser fc = new JnlpFileChooser(); - fc.setSize(400, 300); - fc.setVisible(true); - } -} ///:~ diff --git a/gui/jnlp/filechooser.html b/gui/jnlp/filechooser.html deleted file mode 100644 index 495affc5..00000000 --- a/gui/jnlp/filechooser.html +++ /dev/null @@ -1,5 +0,0 @@ - -Follow the instructions in JnlpFileChooser.java to -build jnlpfilechooser.jar, then: -click here - diff --git a/gui/jnlp/filechooser.jnlp b/gui/jnlp/filechooser.jnlp deleted file mode 100644 index 4e4c3642..00000000 --- a/gui/jnlp/filechooser.jnlp +++ /dev/null @@ -1,24 +0,0 @@ - - - - FileChooser demo application - Mindview Inc. - - Jnlp File chooser Application - - - Demonstrates opening, reading and writing a text file - - - - - - - - - - diff --git a/gui/jnlp/mindview.gif b/gui/jnlp/mindview.gif deleted file mode 100644 index 31496411..00000000 Binary files a/gui/jnlp/mindview.gif and /dev/null differ diff --git a/holding/build.xml b/holding/build.xml index 4d4d54bd..27a72eb3 100644 --- a/holding/build.xml +++ b/holding/build.xml @@ -21,7 +21,7 @@ - @@ -30,7 +30,7 @@ - @@ -44,7 +44,7 @@ name="build"> - diff --git a/initialization/build.xml b/initialization/build.xml index 879b0368..fb21bdb4 100644 --- a/initialization/build.xml +++ b/initialization/build.xml @@ -21,7 +21,7 @@ - @@ -35,7 +35,7 @@ name="build"> - - @@ -35,7 +35,7 @@ name="build"> - diff --git a/interfaces/build.xml b/interfaces/build.xml index 79c1fc18..afcafb1d 100644 --- a/interfaces/build.xml +++ b/interfaces/build.xml @@ -21,7 +21,7 @@ - @@ -30,7 +30,7 @@ - @@ -44,7 +44,7 @@ name="build"> - diff --git a/io/BasicFileOutput.out b/io/BasicFileOutput.out new file mode 100644 index 00000000..e1dc97e3 --- /dev/null +++ b/io/BasicFileOutput.out @@ -0,0 +1,21 @@ +1: //: io/BasicFileOutput.java +2: import java.io.*; +3: +4: public class BasicFileOutput { +5: static String file = "BasicFileOutput.out"; +6: public static void main(String[] args) +7: throws IOException { +8: BufferedReader in = new BufferedReader( +9: new StringReader( +10: BufferedInputFile.read("BasicFileOutput.java"))); +11: PrintWriter out = new PrintWriter( +12: new BufferedWriter(new FileWriter(file))); +13: int lineCount = 1; +14: String s; +15: while((s = in.readLine()) != null ) +16: out.println(lineCount++ + ": " + s); +17: out.close(); +18: // Show the stored file: +19: System.out.println(BufferedInputFile.read(file)); +20: } +21: } /* (Execute to see output) *///:~ diff --git a/io/Blip3.out b/io/Blip3.out new file mode 100644 index 00000000..5f5fb2a2 Binary files /dev/null and b/io/Blip3.out differ diff --git a/io/Blips.out b/io/Blips.out new file mode 100644 index 00000000..6e9200ea Binary files /dev/null and b/io/Blips.out differ diff --git a/io/CADState.out b/io/CADState.out new file mode 100644 index 00000000..9c097b62 Binary files /dev/null and b/io/CADState.out differ diff --git a/io/FileOutputShortcut.out b/io/FileOutputShortcut.out new file mode 100644 index 00000000..6223c02d --- /dev/null +++ b/io/FileOutputShortcut.out @@ -0,0 +1,21 @@ +1: //: io/FileOutputShortcut.java +2: import java.io.*; +3: +4: public class FileOutputShortcut { +5: static String file = "FileOutputShortcut.out"; +6: public static void main(String[] args) +7: throws IOException { +8: BufferedReader in = new BufferedReader( +9: new StringReader( +10: BufferedInputFile.read("FileOutputShortcut.java"))); +11: // Here's the shortcut: +12: PrintWriter out = new PrintWriter(file); +13: int lineCount = 1; +14: String s; +15: while((s = in.readLine()) != null ) +16: out.println(lineCount++ + ": " + s); +17: out.close(); +18: // Show the stored file: +19: System.out.println(BufferedInputFile.read(file)); +20: } +21: } /* (Execute to see output) *///:~ diff --git a/io/Logon.out b/io/Logon.out new file mode 100644 index 00000000..bd67266e Binary files /dev/null and b/io/Logon.out differ diff --git a/io/TransferTo.txt b/io/TransferTo.txt new file mode 100644 index 00000000..ca84219b --- /dev/null +++ b/io/TransferTo.txt @@ -0,0 +1,20 @@ +//: io/TransferTo.java +// Using transferTo() between channels +// {Args: TransferTo.java TransferTo.txt} +import java.nio.channels.*; +import java.io.*; + +public class TransferTo { + public static void main(String[] args) throws Exception { + if(args.length != 2) { + System.out.println("arguments: sourcefile destfile"); + System.exit(1); + } + FileChannel + in = new FileInputStream(args[0]).getChannel(), + out = new FileOutputStream(args[1]).getChannel(); + in.transferTo(0, in.size(), out); + // Or: + // out.transferFrom(in, 0, in.size()); + } +} ///:~ diff --git a/io/X.file b/io/X.file new file mode 100644 index 00000000..93cc6951 Binary files /dev/null and b/io/X.file differ diff --git a/io/build.xml b/io/build.xml index 4c7bca47..2022c239 100644 --- a/io/build.xml +++ b/io/build.xml @@ -21,7 +21,7 @@ - @@ -35,7 +35,7 @@ name="build"> - diff --git a/io/data.txt b/io/data.txt new file mode 100644 index 00000000..09f4a764 Binary files /dev/null and b/io/data.txt differ diff --git a/io/data2.txt b/io/data2.txt new file mode 100644 index 00000000..7db4285e Binary files /dev/null and b/io/data2.txt differ diff --git a/io/file.txt b/io/file.txt new file mode 100644 index 00000000..e69de29b diff --git a/io/rtest.dat b/io/rtest.dat new file mode 100644 index 00000000..a3c24bba Binary files /dev/null and b/io/rtest.dat differ diff --git a/io/temp.tmp b/io/temp.tmp new file mode 100644 index 00000000..c04880a7 Binary files /dev/null and b/io/temp.tmp differ diff --git a/io/test.gz b/io/test.gz new file mode 100644 index 00000000..7382a1fa Binary files /dev/null and b/io/test.gz differ diff --git a/io/test.out b/io/test.out new file mode 100644 index 00000000..da451b28 --- /dev/null +++ b/io/test.out @@ -0,0 +1,25 @@ +//: io/Redirecting.java +// Demonstrates standard I/O redirection. +import java.io.*; + +public class Redirecting { + public static void main(String[] args) + throws IOException { + PrintStream console = System.out; + BufferedInputStream in = new BufferedInputStream( + new FileInputStream("Redirecting.java")); + PrintStream out = new PrintStream( + new BufferedOutputStream( + new FileOutputStream("test.out"))); + System.setIn(in); + System.setOut(out); + System.setErr(out); + BufferedReader br = new BufferedReader( + new InputStreamReader(System.in)); + String s; + while((s = br.readLine()) != null) + System.out.println(s); + out.close(); // Remember this! + System.setOut(console); + } +} ///:~ diff --git a/io/test.txt b/io/test.txt new file mode 100644 index 00000000..2967e3ef --- /dev/null +++ b/io/test.txt @@ -0,0 +1,25 @@ +//: io/ChannelCopy.java +// Copying a file using channels and buffers +// {Args: ChannelCopy.java test.txt} +import java.nio.*; +import java.nio.channels.*; +import java.io.*; + +public class ChannelCopy { + private static final int BSIZE = 1024; + public static void main(String[] args) throws Exception { + if(args.length != 2) { + System.out.println("arguments: sourcefile destfile"); + System.exit(1); + } + FileChannel + in = new FileInputStream(args[0]).getChannel(), + out = new FileOutputStream(args[1]).getChannel(); + ByteBuffer buffer = ByteBuffer.allocate(BSIZE); + while(in.read(buffer) != -1) { + buffer.flip(); // Prepare for writing + out.write(buffer); + buffer.clear(); // Prepare for reading + } + } +} ///:~ diff --git a/io/test.zip b/io/test.zip new file mode 100644 index 00000000..e0adb799 Binary files /dev/null and b/io/test.zip differ diff --git a/io/worm.out b/io/worm.out new file mode 100644 index 00000000..b96ee23d Binary files /dev/null and b/io/worm.out differ diff --git a/net/build.xml b/net/build.xml index 21e0a564..4f4c6d9f 100644 --- a/net/build.xml +++ b/net/build.xml @@ -25,7 +25,7 @@ property="javassist.bytecode.ClassFile"/> - @@ -40,9 +40,9 @@ + message="You must install the Javassist library from www.javassist.org"/> - diff --git a/net/mindview/atunit/AtUnitRemover.java b/net/mindview/atunit/AtUnitRemover.java index 1532e81f..a8834d1e 100644 --- a/net/mindview/atunit/AtUnitRemover.java +++ b/net/mindview/atunit/AtUnitRemover.java @@ -4,7 +4,7 @@ // {Args: ..} // {Requires: javassist.bytecode.ClassFile; // You must install the Javassist library from -// http://sourceforge.net/projects/jboss/ } +// www.javassist.org } package net.mindview.atunit; import javassist.*; import javassist.expr.*; diff --git a/net/mindview/util/test.txt b/net/mindview/util/test.txt new file mode 100644 index 00000000..eaaf9bd1 --- /dev/null +++ b/net/mindview/util/test.txt @@ -0,0 +1,82 @@ +//: net/mindview/util/TextFile.java +// Static functions for reading and writing text files as +// a single string, and treating a file as an ArrayList. +package net.mindview.util; +import java.io.*; +import java.util.*; + +public class TextFile extends ArrayList { + // Read a file as a single string: + public static String read(String fileName) { + StringBuilder sb = new StringBuilder(); + try { + BufferedReader in= new BufferedReader(new FileReader( + new File(fileName).getAbsoluteFile())); + try { + String s; + while((s = in.readLine()) != null) { + sb.append(s); + sb.append("\n"); + } + } finally { + in.close(); + } + } catch(IOException e) { + throw new RuntimeException(e); + } + return sb.toString(); + } + // Write a single file in one method call: + public static void write(String fileName, String text) { + try { + PrintWriter out = new PrintWriter( + new File(fileName).getAbsoluteFile()); + try { + out.print(text); + } finally { + out.close(); + } + } catch(IOException e) { + throw new RuntimeException(e); + } + } + // Read a file, split by any regular expression: + public TextFile(String fileName, String splitter) { + super(Arrays.asList(read(fileName).split(splitter))); + // Regular expression split() often leaves an empty + // String at the first position: + if(get(0).equals("")) remove(0); + } + // Normally read by lines: + public TextFile(String fileName) { + this(fileName, "\n"); + } + public void write(String fileName) { + try { + PrintWriter out = new PrintWriter( + new File(fileName).getAbsoluteFile()); + try { + for(String item : this) + out.println(item); + } finally { + out.close(); + } + } catch(IOException e) { + throw new RuntimeException(e); + } + } + // Simple test: + public static void main(String[] args) { + String file = read("TextFile.java"); + write("test.txt", file); + TextFile text = new TextFile("test.txt"); + text.write("test2.txt"); + // Break into unique sorted list of words: + TreeSet words = new TreeSet( + new TextFile("TextFile.java", "\\W+")); + // Display the capitalized words: + System.out.println(words.headSet("a")); + } +} /* Output: +[0, ArrayList, Arrays, Break, BufferedReader, BufferedWriter, Clean, Display, File, FileReader, FileWriter, IOException, Normally, Output, PrintWriter, Read, Regular, RuntimeException, Simple, Static, String, StringBuilder, System, TextFile, Tools, TreeSet, W, Write] +*///:~ diff --git a/net/mindview/util/test2.txt b/net/mindview/util/test2.txt new file mode 100644 index 00000000..eaaf9bd1 --- /dev/null +++ b/net/mindview/util/test2.txt @@ -0,0 +1,82 @@ +//: net/mindview/util/TextFile.java +// Static functions for reading and writing text files as +// a single string, and treating a file as an ArrayList. +package net.mindview.util; +import java.io.*; +import java.util.*; + +public class TextFile extends ArrayList { + // Read a file as a single string: + public static String read(String fileName) { + StringBuilder sb = new StringBuilder(); + try { + BufferedReader in= new BufferedReader(new FileReader( + new File(fileName).getAbsoluteFile())); + try { + String s; + while((s = in.readLine()) != null) { + sb.append(s); + sb.append("\n"); + } + } finally { + in.close(); + } + } catch(IOException e) { + throw new RuntimeException(e); + } + return sb.toString(); + } + // Write a single file in one method call: + public static void write(String fileName, String text) { + try { + PrintWriter out = new PrintWriter( + new File(fileName).getAbsoluteFile()); + try { + out.print(text); + } finally { + out.close(); + } + } catch(IOException e) { + throw new RuntimeException(e); + } + } + // Read a file, split by any regular expression: + public TextFile(String fileName, String splitter) { + super(Arrays.asList(read(fileName).split(splitter))); + // Regular expression split() often leaves an empty + // String at the first position: + if(get(0).equals("")) remove(0); + } + // Normally read by lines: + public TextFile(String fileName) { + this(fileName, "\n"); + } + public void write(String fileName) { + try { + PrintWriter out = new PrintWriter( + new File(fileName).getAbsoluteFile()); + try { + for(String item : this) + out.println(item); + } finally { + out.close(); + } + } catch(IOException e) { + throw new RuntimeException(e); + } + } + // Simple test: + public static void main(String[] args) { + String file = read("TextFile.java"); + write("test.txt", file); + TextFile text = new TextFile("test.txt"); + text.write("test2.txt"); + // Break into unique sorted list of words: + TreeSet words = new TreeSet( + new TextFile("TextFile.java", "\\W+")); + // Display the capitalized words: + System.out.println(words.headSet("a")); + } +} /* Output: +[0, ArrayList, Arrays, Break, BufferedReader, BufferedWriter, Clean, Display, File, FileReader, FileWriter, IOException, Normally, Output, PrintWriter, Read, Regular, RuntimeException, Simple, Static, String, StringBuilder, System, TextFile, Tools, TreeSet, W, Write] +*///:~ diff --git a/object/build.xml b/object/build.xml index 18e746d1..3f2994a9 100644 --- a/object/build.xml +++ b/object/build.xml @@ -26,7 +26,7 @@ name="build"> - diff --git a/annotations/InterfaceExtractorProcessor.java b/obsolete/InterfaceExtractorProcessor.java similarity index 100% rename from annotations/InterfaceExtractorProcessor.java rename to obsolete/InterfaceExtractorProcessor.java diff --git a/annotations/InterfaceExtractorProcessorFactory.java b/obsolete/InterfaceExtractorProcessorFactory.java similarity index 60% rename from annotations/InterfaceExtractorProcessorFactory.java rename to obsolete/InterfaceExtractorProcessorFactory.java index a5025633..5ed41e32 100644 --- a/annotations/InterfaceExtractorProcessorFactory.java +++ b/obsolete/InterfaceExtractorProcessorFactory.java @@ -1,15 +1,15 @@ //: annotations/InterfaceExtractorProcessorFactory.java // APT-based annotation processing. package annotations; -import com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; +/*import com.sun.mirror.apt.*; +import com.sun.mirror.declaration.*;*/ import java.util.*; public class InterfaceExtractorProcessorFactory - implements AnnotationProcessorFactory { - public AnnotationProcessor getProcessorFor( - Set atds, - AnnotationProcessorEnvironment env) { + implements javax.annotation.processing.Processor { + public javax.annotation.processing.Processor getProcessorFor( + Set atds, + javax.annotation.processing.ProcessingEnvironment env) { return new InterfaceExtractorProcessor(env); } public Collection supportedAnnotationTypes() { diff --git a/annotations/database/Constraints.java b/obsolete/database/Constraints.java similarity index 100% rename from annotations/database/Constraints.java rename to obsolete/database/Constraints.java diff --git a/annotations/database/DBTable.java b/obsolete/database/DBTable.java similarity index 100% rename from annotations/database/DBTable.java rename to obsolete/database/DBTable.java diff --git a/annotations/database/Member.java b/obsolete/database/Member.java similarity index 100% rename from annotations/database/Member.java rename to obsolete/database/Member.java diff --git a/annotations/database/SQLInteger.java b/obsolete/database/SQLInteger.java similarity index 100% rename from annotations/database/SQLInteger.java rename to obsolete/database/SQLInteger.java diff --git a/annotations/database/SQLString.java b/obsolete/database/SQLString.java similarity index 100% rename from annotations/database/SQLString.java rename to obsolete/database/SQLString.java diff --git a/annotations/database/TableCreationProcessorFactory.java b/obsolete/database/TableCreationProcessorFactory.java similarity index 100% rename from annotations/database/TableCreationProcessorFactory.java rename to obsolete/database/TableCreationProcessorFactory.java diff --git a/annotations/database/TableCreator.java b/obsolete/database/TableCreator.java similarity index 100% rename from annotations/database/TableCreator.java rename to obsolete/database/TableCreator.java diff --git a/annotations/database/Uniqueness.java b/obsolete/database/Uniqueness.java similarity index 100% rename from annotations/database/Uniqueness.java rename to obsolete/database/Uniqueness.java diff --git a/operators/build.xml b/operators/build.xml index 5f95da77..a00897f9 100644 --- a/operators/build.xml +++ b/operators/build.xml @@ -21,7 +21,7 @@ - @@ -35,7 +35,7 @@ name="build"> - diff --git a/polymorphism/build.xml b/polymorphism/build.xml index ddc2f886..b076f341 100644 --- a/polymorphism/build.xml +++ b/polymorphism/build.xml @@ -21,7 +21,7 @@ - @@ -30,7 +30,7 @@ - @@ -44,7 +44,7 @@ name="build"> - diff --git a/reusing/build.xml b/reusing/build.xml index 72275871..5376d168 100644 --- a/reusing/build.xml +++ b/reusing/build.xml @@ -21,7 +21,7 @@ - @@ -35,7 +35,7 @@ name="build"> - - @@ -30,7 +30,7 @@ - @@ -44,7 +44,7 @@ name="build"> - diff --git a/swt/build.xml b/swt/build.xml index f8841e3f..e27bb197 100644 --- a/swt/build.xml +++ b/swt/build.xml @@ -25,7 +25,7 @@ property="org.eclipse.swt.widgets.Display"/> - @@ -42,7 +42,7 @@ Unless="org.eclipse.swt.widgets.Display" message="You must install the SWT library from http://www.eclipse.org"/> - diff --git a/typeinfo/build.xml b/typeinfo/build.xml index 14575fa7..06276972 100644 --- a/typeinfo/build.xml +++ b/typeinfo/build.xml @@ -21,7 +21,7 @@ - @@ -30,7 +30,7 @@ - @@ -44,7 +44,7 @@ name="build"> - diff --git a/xml/People.xml b/xml/People.xml new file mode 100644 index 00000000..f2c5b975 --- /dev/null +++ b/xml/People.xml @@ -0,0 +1,15 @@ + + + + Dr. Bunsen + Honeydew + + + Gonzo + The Great + + + Phillip J. + Fry + + diff --git a/xml/build.xml b/xml/build.xml index f03e1817..ad3bab43 100644 --- a/xml/build.xml +++ b/xml/build.xml @@ -31,7 +31,7 @@ Unless="nu.xom.Node" message="You must install the XOM library from http://www.xom.nu"/> -