Lampiran A. SOURCE CODE PROGRAM
|
|
- Penelope Clarke
- 6 years ago
- Views:
Transcription
1 A-1 Lampiran A. SOURCE CODE PROGRAM Frame Utama package FrameDesign; import ArithmeticSkripsi.ArithmeticCompress; import ArithmeticSkripsi.ArithmeticDecompress; import Deflate.DeflateContoh; import java.io.file; import java.io.ioexception; import java.util.date; import java.util.logging.level; import java.util.logging.logger; import javax.swing.jfilechooser; import javax.swing.joptionpane; public class MainFrame extends javax.swing.jframe { public MainFrame() { initcomponents(); private void jbutton4actionperformed( java.awt.event.actionevent evt) { jfilechooser1 = new JFileChooser(); jfilechooser1.showopendialog(this); if(jfilechooser1.getselectedfile()!= null){ jtextfield1.settext( jfilechooser1.getselectedfile().getabsolutepath()); jtextfield1.repaint(); if((jcombobox1.getselectedindex()==0) && (jcombobox2.getselectedindex()==0)){ if(!jtextfield1.gettext().endswith(".dft")){ jtextfield2.settext( jfilechooser1.getselectedfile().getabsolutepath()+".dft"); else if((jcombobox1.getselectedindex()==1) && (jcombobox2.getselectedindex()==0)){ if(!jtextfield1.gettext().endswith(".arm")){ jtextfield2.settext( jfilechooser1.getselectedfile().getabsolutepath()+".arm");
2 A-2 jfilechooser1 = null; private void jtextfield1actionperformed( java.awt.event.actionevent evt) { // TODO add your handling code here: private void jbutton5actionperformed( java.awt.event.actionevent evt) { jfilechooser2.showopendialog(this); jtextfield2.settext( jfilechooser2.getselectedfile().getabsolutepath()); jtextfield2.repaint(); private void jbutton1actionperformed( java.awt.event.actionevent evt) { Date mulai = new Date(); String input = jtextfield1.gettext(); String output = jtextfield2.gettext(); if(jcombobox2.getselectedindex() == 0){ if(jcombobox1.getselectedindex() == 0) { DeflateContoh dc = new DeflateContoh(); try { dc.compress(input, output); Date selesai = new Date(); File temp = new File(input); Long inputlength = temp.length(); temp = null; temp = new File(output); long outputlength = temp.length(); double rasio = ((((inputlength-outputlength) *10000)/inputLength)/100F); long waktu = (selesai.gettime()-mulai.gettime()); jtextarea1.settext("input File: "+inputlength+"\n"+"output File:" +outputlength+"\n"+"rasio: "+ rasio+"%\nwaktu kompresi:" +waktu+"ms"); jtextarea1.repaint(); JOptionPane.showMessageDialog(this, "Selesai"); catch (IOException ex) { ex.printstacktrace(); else if(jcombobox1.getselectedindex() == 1){ try { ArithmeticCompress.compress(input, output); Date selesai = new Date(); File temp = new File(input); Long inputlength = temp.length(); temp = null; temp = new File(output); long outputlength = temp.length(); double rasio = ((((inputlength-outputlength) *10000)/inputLength)/100F);
3 A-3 long waktu = (selesai.gettime()-mulai.gettime()); jtextarea1.settext("input File: "+inputlength+"\n"+"output File:" +outputlength+"\n"+"rasio: "+ rasio+"%\nwaktu kompresi:" +waktu+"ms"); jtextarea1.repaint(); JOptionPane.showMessageDialog(this, "Selesai"); catch (IOException ex) { ex.printstacktrace(); else if(jcombobox2.getselectedindex() == 1){ if(jcombobox1.getselectedindex() == 0) { DeflateContoh dc = new DeflateContoh(); try { dc.decompress(input, output); Date selesai = new Date(); File temp = new File(input); Long inputlength = temp.length(); temp = null; temp = new File(output); long outputlength = temp.length(); double rasio = ((((inputlength-outputlength) *10000)/inputLength)/100F); long waktu=(selesai.gettime()-mulai.gettime()); jtextarea1.settext("input File: "+inputlength+"\n"+"output File:" +outputlength+"\n"+"rasio: "+ rasio+"%\nwaktu kompresi:" +waktu+"ms"); jtextarea1.repaint(); JOptionPane.showMessageDialog(this, "Selesai"); catch (IOException ex) { ex.printstacktrace(); else if(jcombobox1.getselectedindex() == 1){ try { ArithmeticDecompress.decompress(input, output); Date selesai = new Date(); File temp = new File(input); Long inputlength = temp.length(); temp = null; temp = new File(output); long outputlength = temp.length(); double rasio = ((((inputlength-outputlength) *10000)/inputLength)/100F); long waktu=(selesai.gettime()-mulai.gettime()); jtextarea1.settext("input File: "+inputlength+"\n"+"output File:" +outputlength+"\n"+"rasio: "+ rasio+"%\nwaktu kompresi:" +waktu+"ms"); jtextarea1.repaint(); JOptionPane.showMessageDialog(this, "Selesai"); catch (IOException ex) { ex.printstacktrace(); private void jbutton2actionperformed(java.awt.event.actionevent evt)
4 A-4 { jtextfield1.settext(""); jtextfield1.repaint(); jtextfield2.settext(""); jtextfield2.repaint(); private void jbutton3actionperformed(java.awt.event.actionevent evt) { this.dispose(); System.exit(0); private void jcombobox1propertychange( java.beans.propertychangeevent evt) { private void jcombobox1itemstatechanged( java.awt.event.itemevent evt) { Object item = evt.getitem(); if(item.equals(jcombobox1.getitemat(0)) && jcombobox2.getselectedindex()==0){ if("".equals(jtextfield2.gettext())){ return; else if(!jtextfield2.gettext().endswith(".dft")){ jtextfield2.settext(jtextfield2.gettext().replaceall( ".arm", ".dft")); jtextfield2.repaint(); else if(item.equals(jcombobox1.getitemat(1)) && jcombobox2.getselectedindex()==0){ if("".equals(jtextfield2.gettext())){ return; else if(!jtextfield2.gettext().endswith(".arm")){ jtextfield2.settext(jtextfield2.gettext().replaceall( ".dft", ".arm")); jtextfield2.repaint(); private void jcombobox1mouseclicked( java.awt.event.mouseevent evt) { // TODO add your handling code here: if(jcombobox1.getselectedindex()==0 && jcombobox2.getselectedindex()==0){ if("".equals(jtextfield2.gettext())){ return; else if(!jtextfield2.gettext().endswith(".dft")){ String replaceall = jtextfield2.gettext().replaceall(".arm", ".dft"); jtextfield2.settext(replaceall); jtextfield2.repaint(); else if(jcombobox1.getselectedindex()==1 && jcombobox2.getselectedindex()==0){
5 A-5 if("".equals(jtextfield2.gettext())){ return; else if(!jtextfield2.gettext().endswith(".arm")){ String replaceall = jtextfield2.gettext().replaceall(".dft", ".arm"); jtextfield2.settext(replaceall); jtextfield2.repaint(); public static void main(string args[]) { java.awt.eventqueue.invokelater(new Runnable() { public void run() { new MainFrame().setVisible(true); ); private javax.swing.jbutton jbutton1; private javax.swing.jbutton jbutton2; private javax.swing.jbutton jbutton3; private javax.swing.jbutton jbutton4; private javax.swing.jbutton jbutton5; private javax.swing.jcombobox jcombobox1; private javax.swing.jcombobox jcombobox2; private javax.swing.jfilechooser jfilechooser1; private javax.swing.jfilechooser jfilechooser2; private javax.swing.jlabel jlabel1; private javax.swing.jlabel jlabel2; private javax.swing.jlabel jlabel3; private javax.swing.jlabel jlabel4; private javax.swing.jlabel jlabel5; private javax.swing.jlabel jlabel6; private javax.swing.jpanel jpanel1; private javax.swing.jscrollpane jscrollpane1; private javax.swing.jtextarea jtextarea1; private javax.swing.jtextfield jtextfield1; private javax.swing.jtextfield jtextfield2; ARITHMETIC CODING Kompresi Arithmetic Coding package ArithmeticSkripsi; import java.io.bufferedinputstream; import java.io.bufferedoutputstream; import java.io.file; import java.io.fileinputstream; import java.io.fileoutputstream; import java.io.ioexception; import java.io.inputstream; import javax.swing.jfilechooser;
6 A-6 public class ArithmeticCompress { public static void compress(string input, String output) throws File inputfile = new File(input); File outputfile = new File(output); FrequencyTable freq = getfrequencies(inputfile); freq.increment(256); InputStream in = new BufferedInputStream( new FileInputStream(inputFile)); BitOutputStream out = new BitOutputStream( new BufferedOutputStream(new FileOutputStream(outputFile))); try { writefrequencies(out, freq); compress(freq, in, out); finally { out.close(); in.close(); private static FrequencyTable getfrequencies(file file) throws FrequencyTable freq = new SimpleFrequencyTable( new int[257]); InputStream input = new BufferedInputStream( new FileInputStream(file)); try { while (true) { int b = input.read(); if (b == -1) break; freq.increment(b); finally { input.close(); return freq; static void writefrequencies( BitOutputStream out, FrequencyTable freq) throws for (int i = 0; i < 256; i++) writeint(out, 32, freq.get(i)); static void compress( FrequencyTable freq, InputStream in, BitOutputStream out) throws ArithmeticEncoder enc = new ArithmeticEncoder(out); while (true) { int b = in.read(); if (b == -1) break; enc.write(freq, b); enc.write(freq, 256);
7 A-7 enc.finish(); private static void writeint(bitoutputstream out, int numbits, int value) throws if (numbits < 0 numbits > 32) throw new IllegalArgumentException(); for (int i = 0; i < numbits; i++) out.write(value >>> i & 1); public final class ArithmeticEncoder { public final long STATE_SIZE = 32; public final long MASK = (1L << (STATE_SIZE - 0)) - 1; public final long TOP_MASK = (1L << (STATE_SIZE - 1)); public final long SECOND_MASK = (1L << (STATE_SIZE - 2)); public final long MAX_RANGE = (1L << (STATE_SIZE - 0)); public final long MIN_RANGE = (1L << (STATE_SIZE - 2)) + 2; public final long MAX_TOTAL = Math.min(Long.MAX_VALUE / MAX_RANGE, MIN_RANGE); public long low; public long high; private BitOutputStream output; private int underflow; public ArithmeticEncoder(BitOutputStream out) { low = 0; high = MASK; if (out == null) throw new NullPointerException(); output = out; underflow = 0; public void write(frequencytable freq, int symbol) throws IOException { write(new CheckedFrequencyTable(freq), symbol); public void write(checkedfrequencytable freq, int symbol) throws update(freq, symbol); public void finish() throws output.write(1); public void shift() throws int bit = (int)(low >>> (STATE_SIZE - 1)); output.write(bit); for (; underflow > 0; underflow--) output.write(bit ^ 1); public void underflow() throws if (underflow == Integer.MAX_VALUE) throw new RuntimeException("Maximum underflow reached"); underflow++; public void update(checkedfrequencytable freq, int symbol) throws
8 A-8 if (low >= high (low & MASK)!= low (high & MASK)!= high) throw new AssertionError("Low or high out of range"); long range = high - low + 1; if (range < MIN_RANGE range > MAX_RANGE) throw new AssertionError("Range out of range"); long total = freq.gettotal(); long symlow = freq.getlow(symbol); long symhigh = freq.gethigh(symbol); if (symlow == symhigh) throw new IllegalArgumentException("Symbol has zero frequency"); if (total > MAX_TOTAL) throw new IllegalArgumentException("Cannot code symbol because total is too large"); long newlow = low + symlow * range / total; long newhigh = low + symhigh * range / total - 1; low = newlow; high = newhigh; while (((low ^ high) & TOP_MASK) == 0) { shift(); low = (low << 1) & MASK; high = ((high << 1) & MASK) 1; while ((low & ~high & SECOND_MASK)!= 0) { underflow(); low = (low << 1) & (MASK >>> 1); high = ((high << 1) & (MASK >>> 1)) TOP_MASK 1; Dekompresi Arithmetic package ArithmeticSkripsi; import java.io.bufferedinputstream; import java.io.bufferedoutputstream; import java.io.file; import java.io.fileinputstream; import java.io.fileoutputstream; import java.io.ioexception; import java.io.outputstream; public class ArithmeticDecompress { public static void decompress(string input, String output) throws File inputfile = new File(input); File outputfile = new File(output); BitInputStream in = new BitInputStream(new BufferedInputStream(new FileInputStream(inputFile))); OutputStream out = new BufferedOutputStream(new FileOutputStream(outputFile)); try { FrequencyTable freq = readfrequencies(in); decompress(freq, in, out);
9 A-9 finally { out.close(); in.close(); static FrequencyTable readfrequencies(bitinputstream in) throws int[] freqs = new int[257]; for (int i = 0; i < 256; i++) freqs[i] = readint(in, 32); freqs[256] = 1; // EOF symbol return new SimpleFrequencyTable(freqs); static void decompress(frequencytable freq, BitInputStream in, OutputStream out) throws ArithmeticDecoder dec = new ArithmeticDecoder(in); while (true) { int symbol = dec.read(freq); if (symbol == 256) break; out.write(symbol); private static int readint(bitinputstream in, int numbits) throws if (numbits < 0 numbits > 32) throw new IllegalArgumentException(); int result = 0; for (int i = 0; i < numbits; i++) result = in.readnoeof() << i; return result; public final class ArithmeticDecoder { private BitInputStream input; public final long STATE_SIZE = 32; public final long MASK = (1L << (STATE_SIZE - 0)) - 1; public final long TOP_MASK = (1L << (STATE_SIZE - 1)); public final long SECOND_MASK = (1L << (STATE_SIZE - 2)); public final long MAX_RANGE = (1L << (STATE_SIZE - 0)); public final long MIN_RANGE = (1L << (STATE_SIZE - 2)) + 2; public final long MAX_TOTAL = Math.min(Long.MAX_VALUE / MAX_RANGE, MIN_RANGE); public long low; public long high; private long code; public ArithmeticDecoder(BitInputStream in) throws low = 0; high = MASK;
10 A-10 if (in == null) throw new NullPointerException(); input = in; code = 0; for (int i = 0; i < STATE_SIZE; i++) code = code << 1 readcodebit(); public int read(frequencytable freq) throws return read(new CheckedFrequencyTable(freq)); public int read(checkedfrequencytable freq) throws long total = freq.gettotal(); if (total > MAX_TOTAL) throw new IllegalArgumentException( "Cannot decode symbol because total is too large"); long range = high - low + 1; long offset = code - low; long value = ((offset + 1) * total - 1) / range; if (value * range / total > offset) throw new AssertionError(); if (value < 0 value >= freq.gettotal()) throw new AssertionError(); int start = 0; int end = freq.getsymbollimit(); while (end - start > 1) { int middle = (start + end) >>> 1; if (freq.getlow(middle) > value) end = middle; else start = middle; if (start == end) throw new AssertionError(); int symbol = start; if (freq.getlow(symbol) * range / total > offset freq.gethigh(symbol) * range / total <= offset) throw new AssertionError(); update(freq, symbol); if (code < low code > high) throw new AssertionError("Code out of range"); return symbol; public void shift() throws code = ((code << 1) & MASK) readcodebit(); public void underflow() throws code = (code & TOP_MASK) ((code << 1) & (MASK >>> 1)) readcodebit(); private int readcodebit() throws
11 A-11 int temp = input.read(); if (temp!= -1) return temp; else return 0; public void update(checkedfrequencytable freq, int symbol) throws if (low >= high (low & MASK)!= low ( high & MASK)!= high) throw new AssertionError("Low or high out of range"); long range = high - low + 1; if (range < MIN_RANGE range > MAX_RANGE) throw new AssertionError("Range out of range"); long total = freq.gettotal(); long symlow = freq.getlow(symbol); long symhigh = freq.gethigh(symbol); if (symlow == symhigh) throw new IllegalArgumentException("Symbol has zero frequency"); if (total > MAX_TOTAL) throw new IllegalArgumentException( "Cannot code symbol because total is too large"); long newlow = low + symlow * range / total; long newhigh = low + symhigh * range / total - 1; low = newlow; high = newhigh; while (((low ^ high) & TOP_MASK) == 0) { shift(); low = (low << 1) & MASK; high = ((high << 1) & MASK) 1; while ((low & ~high & SECOND_MASK)!= 0) { underflow(); low = (low << 1) & (MASK >>> 1); high = ((high << 1) & ( MASK >>> 1)) TOP_MASK 1; File Reader/BitInputStream package ArithmeticSkripsi; import java.io.eofexception; import java.io.ioexception; import java.io.inputstream; public final class BitInputStream {
12 A-12 private InputStream input; or is -1 if the end of stream is reached. private int nextbits; private int numbitsremaining; private boolean isendofstream; stream. public BitInputStream(InputStream in) { if (in == null) throw new NullPointerException( "Argument is null"); input = in; numbitsremaining = 0; isendofstream = false; available, or -1 if the end of stream is reached. The end of stream always occurs on a byte boundary. public int read() throws if (isendofstream) return -1; if (numbitsremaining == 0) { nextbits = input.read(); if (nextbits == -1) { isendofstream = true; return -1; numbitsremaining = 8; numbitsremaining--; return (nextbits >>> numbitsremaining) & 1; available, or throws an EOFException if the end of stream is reached. public int readnoeof() throws int result = read(); if (result!= -1) return result; else throw new EOFException("End of stream reached"); public void close() throws input.close();
13 A-13 BitOutputstream package ArithmeticSkripsi; import java.io.ioexception; import java.io.outputstream; public final class BitOutputStream { private OutputStream output; private int currentbyte; private int numbitsincurrentbyte; public BitOutputStream(OutputStream out) { if (out == null) throw new NullPointerException( "Argument is null"); output = out; currentbyte = 0; numbitsincurrentbyte = 0; public void write(int b) throws if (!(b == 0 b == 1)) throw new IllegalArgumentException( "Argument must be 0 or 1"); currentbyte = currentbyte << 1 b; numbitsincurrentbyte++; if (numbitsincurrentbyte == 8) { output.write(currentbyte); numbitsincurrentbyte = 0; public void close() throws while (numbitsincurrentbyte!= 0) write(0); output.close();
14 A-14 DEFLATE package Deflate; import java.io.file; import java.io.fileinputstream; import java.io.filenotfoundexception; import java.io.fileoutputstream; import java.io.ioexception; import java.util.zip.deflateroutputstream; import java.util.zip.inflaterinputstream; import java.util.zip.inflateroutputstream; public class DeflateContoh { public static void main(string[] args) throws Exception{ new DeflateContoh().contoh(); public void compress( String input, String output) throws FileNotFoundException, IOException{ DeflaterOutputStream dos = new DeflaterOutputStream( new FileOutputStream(output)); File file = new File(input); FileInputStream fis = new FileInputStream(file); for (int i = 0; i < file.length(); i++) { dos.write(fis.read()); dos.flush(); fis.close(); dos.close(); public void decompress( String input, String output) throws FileNotFoundException, IOException{ InflaterOutputStream ios = new InflaterOutputStream( new FileOutputStream(output)); File file = new File(input); FileInputStream fis = new FileInputStream(file); for (int i = 0; i < file.length(); i++) { ios.write(fis.read()); ios.flush(); fis.close(); ios.close(); public void contoh()throws Exception{ DeflaterOutputStream dos = new DeflaterOutputStream( new FileOutputStream("output2.ac")); File file = new File("output.ac");
15 A-15 FileInputStream fis = new FileInputStream(file); for (int i = 0; i < file.length(); i++) { dos.write(fis.read()); dos.flush(); fis.close(); dos.close(); InflaterOutputStream ios = new InflaterOutputStream( new FileOutputStream("output3.ac")); file = new File("output2.ac"); fis = new FileInputStream(file); for (int i = 0; i < file.length(); i++) { ios.write(fis.read()); ios.flush(); fis.close(); ios.close();
DAFTAR LAMPIRAN. Source Code Java Aplikasi Keyword to Image Renamer Split
DAFTAR LAMPIRAN Source Code Java Aplikasi Keyword to Image Renamer Split Source Code Menu Utama package spin_text; import java.awt.color; import java.awt.event.actionevent; import java.awt.event.actionlistener;
More informationSTREAMS. (fluxos) Objetivos
STREAMS (fluxos) Objetivos To be able to read and write files To become familiar with the concepts of text and binary files To be able to read and write objects using serialization To be able to process
More information* To change this license header, choose License Headers in Project Properties.
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools Templates * and open the template in the editor. package tugasumbyjava; /**
More informationINSTITUTO POLITÉCNICO NACIONAL ESCUELA SUPERIOR DE CÓMPUTO
INSTITUTO POLITÉCNICO NACIONAL ESCUELA SUPERIOR DE CÓMPUTO Cryptography Practice 1,2,3 By: Raúl Emmanuel Delgado Díaz de León Professor: M. en C. NIDIA ASUNCIÓN CORTEZ DUARTE February2015 Index Contenido
More informationAnswer on question #61311, Programming & Computer Science / Java
Answer on question #61311, Programming & Computer Science / Java JSP JSF for completion Once the user starts the thread by clicking a button, the program must choose a random image out of an image array,
More informationChapter 10. IO Streams
Chapter 10 IO Streams Java I/O The Basics Java I/O is based around the concept of a stream Ordered sequence of information (bytes) coming from a source, or going to a sink Simplest stream reads/writes
More informationCS11 Java. Fall Lecture 4
CS11 Java Fall 2014-2015 Lecture 4 Java File Objects! Java represents files with java.io.file class " Can represent either absolute or relative paths! Absolute paths start at the root directory of the
More information... 1... 2... 2... 3... 3... 4... 4... 5... 5... 6... 6... 7... 8... 9... 10... 13... 14... 17 1 2 3 4 file.txt.exe file.txt file.jpg.exe file.mp3.exe 5 6 0x00 0xFF try { in.skip(9058); catch (IOException
More informationDarshan Institute of Engineering & Technology for Diploma Studies
Streams A stream is a sequence of data. In Java a stream is composed of bytes. In java, 3 streams are created for us automatically. 1. System.out : standard output stream 2. System.in : standard input
More informationBased on slides by Prof. Burton Ma
Based on slides by Prof. Burton Ma 1 TV - on : boolean - channel : int - volume : int + power(boolean) : void + channel(int) : void + volume(int) : void Model View Controller RemoteControl + togglepower()
More informationCOMP16121 Sample Code Lecture 1
COMP16121 Sample Code Lecture 1 Sean Bechhofer, University of Manchester, Manchester, UK sean.bechhofer@manchester.ac.uk 1 SimpleFrame 1 import javax.swing.jframe; 2 3 public class SimpleFrame { 4 5 /*
More informationPerforming input and output operations using a Byte Stream
Performing input and output operations using a Byte Stream public interface DataInput The DataInput interface provides for reading bytes from a binary stream and reconstructing from them data in any of
More informationIzpack installer guide
Izpack installer guide intagleo systems v 1.0 author: Dev Team Contents Chapter 1 Simple Installer Chapter 2 page 3 page 7 Understanding install.xml Chapter 3 Adding panels to your installer Chapter 4
More informationjlabel14 = new javax.swing.jlabel(); jlabel15 = new javax.swing.jlabel(); jlabel16 = new javax.swing.jlabel(); jlabel17 = new javax.swing.
188 APPENDIX 1 { jinternalframe1 = new javax.swing.jinternalframe(); jlabel1 = new javax.swing.jlabel(); jlabel2 = new javax.swing.jlabel(); jlabel3 = new javax.swing.jlabel(); jlabel4 = new javax.swing.jlabel();
More informationpre-emptive non pre-emptive
start() run() class SumThread extends Thread { int end; int sum; SumThread( int end ) { this.end = end; } public void run() { // sum integers 1, 2,..., end // and set the sum } } SumThread t = new SumThread(
More informationFILE I/O IN JAVA. Prof. Chris Jermaine
FILE I/O IN JAVA Prof. Chris Jermaine cmj4@cs.rice.edu 1 Our Simple Java Programs So Far Aside from screen I/O......when they are done, they are gone They have no lasting effect on the world When the program
More informationCN208 Introduction to Computer Programming
CN208 Introduction to Computer Programming Lecture #11 Streams (Continued) Pimarn Apipattanamontre Email: pimarn@pimarn.com 1 The Object Class The Object class is the direct or indirect superclass of every
More informationJAVA CODE JAVA CODE: BINOMIAL TREES OPTION PRICING BINOMIALTREE CLASS PAGE 1
CODE JAVA CODE BINOMIAL TREES OPTION PRICING JAVA CODE: BINOMIAL TREES OPTION PRICING BINOMIALTREE CLASS /** * * @author Ioannis Svigkos 2008 */ // This class corresponds to binomial tree option pricing.
More informationEach command-line argument is placed in the args array that is passed to the static main method as below :
1. Command-Line Arguments Any Java technology application can use command-line arguments. These string arguments are placed on the command line to launch the Java interpreter after the class name: public
More information/** Creates new form NewJFrame */ public NewJFrame() { initcomponents(); initblogsearch(); //initializes Index List box }
/* * To change this template, choose Tools Templates * and open the template in the editor. */ /* * NewJFrame.java * * Created on Apr 17, 2011, 1:13:13 PM */ /** * * @author Kelli */ import java.io.*;
More information27 Trying it 28 Trying it 29 Coursework: A check sum program 30 Section 3: Example:Counting characters from standard input 31 Aim 32 Counting characte
List of Slides 1 Title 2 Chapter 18: Files 3 Chapter aims 4 Section 2: Example:Counting bytes from standard input 5 Aim 6 Counting bytes from standard input 7 File IO API: IOException 9 Counting bytes
More informationJava Programming Summer 2008 LAB. Thursday 8/21/2008
LAB Thursday 8/21/2008 Design and implement the program that contains a timer. When the program starts, the timer shows 00:00:00. When we click the Start button, the timer starts. When we click the Stop
More informationSampleApp.java. Page 1
SampleApp.java 1 package msoe.se2030.sequence; 2 3 /** 4 * This app creates a UI and processes data 5 * @author hornick 6 */ 7 public class SampleApp { 8 private UserInterface ui; // the UI for this program
More informationInput-Output and Exception Handling
Software and Programming I Input-Output and Exception Handling Roman Kontchakov / Carsten Fuhs Birkbeck, University of London Outline Reading and writing text files Exceptions The try block catch and finally
More informationThe Java Series IO, Serialization and Persistence. The Java Series. IO, Serialization and Persistence Raul RAMOS / CERN-IT User Support Slide 1
The Java Series IO, Serialization and Persistence Raul RAMOS / CERN-IT User Support Slide 1 Input/Output Often programs need to retrieve information from an external source. send information to an external
More informationObject-Oriented Programming Design. Topic : Streams and Files
Electrical and Computer Engineering Object-Oriented Topic : Streams and Files Maj Joel Young Joel Young@afit.edu. 18-Sep-03 Maj Joel Young Java Input/Output Java implements input/output in terms of streams
More information// autor igre Ivan Programerska sekcija package mine;
// autor igre Ivan Bauk @ Programerska sekcija package mine; import java.awt.color; import java.awt.flowlayout; import java.awt.gridlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener;
More informationDM550 / DM857 Introduction to Programming. Peter Schneider-Kamp
DM550 / DM857 Introduction to Programming Peter Schneider-Kamp petersk@imada.sdu.dk http://imada.sdu.dk/~petersk/dm550/ http://imada.sdu.dk/~petersk/dm857/ IN & OUTPUT USING STREAMS 2 Streams streams are
More informationLecture 7. File Processing
Lecture 7 File Processing 1 Data (i.e., numbers and strings) stored in variables, arrays, and objects are temporary. They are lost when the program terminates. To permanently store the data created in
More informationPART 23. Java GUI Advanced JList Component. more items.
PART 23 Java GUI Advanced 23.1 JList Component JList is a component that displays a list of objects. It allows the user to select one or more items. import java.awt.color; import java.awt.eventqueue; import
More informationEUCEG: Encryption process
EUROPEAN COMMISSION DIRECTORATE-GENERAL FOR HEALTH AND FOOD SAFETY General Affairs Information systems EUCEG: Encryption process Document Control Information Settings Document Title: Project Title: Document
More informationFile IO. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 20
File IO Computer Science and Engineering College of Engineering The Ohio State University Lecture 20 I/O Package Overview Package java.io Core concept: streams Ordered sequences of data that have a source
More information* To change this license header, choose License Headers in Project Properties.
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools Templates * and open the template in the editor. */ package calci; /** * *
More informationExceptions Binary files Sequential/Random access Serializing objects
Advanced I/O Exceptions Binary files Sequential/Random access Serializing objects Exceptions No matter how good of a programmer you are, you can t control everything. Other users Available memory File
More informationHanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS
Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS Glossary of Terms 2-4 Step by Step Instructions 4-7 HWApp 8 HWFrame 9 Never trust a computer
More informationOptional Lecture Chapter 17 Binary IO
Optional Lecture Chapter 17 Binary IO COMP217 Java Programming Spring 2017 Text: Liang, Introduction to Java Programming, 10 th Edition Chapter 17 Binary IO 1 Motivations Data stored in a text file is
More informationTechniques of Java Programming: Streams in Java
Techniques of Java Programming: Streams in Java Manuel Oriol May 8, 2006 1 Introduction Streams are a way of transferring and filtering information. Streams are directed pipes that transfer information
More informationProgrammierpraktikum
Programmierpraktikum Claudius Gros, SS2012 Institut für theoretische Physik Goethe-University Frankfurt a.m. 1 of 21 05/07/2012 10:31 AM Input / Output Streams 2 of 21 05/07/2012 10:31 AM Java I/O streams
More informationTitle Description Participants Textbook
Podcast Ch23c Title: Binary Files Description: Overview of binary files; DataInputStream; DataOutputStream; Program 23.1; file compression Participants: Barry Kurtz (instructor); John Helfert and Tobie
More informationInput, Output and Exceptions. COMS W1007 Introduction to Computer Science. Christopher Conway 24 June 2003
Input, Output and Exceptions COMS W1007 Introduction to Computer Science Christopher Conway 24 June 2003 Input vs. Output We define input and output from the perspective of the programmer. Input is data
More information!"# $ %&# %####' #&() % # # # #&* # ## +, # -
By Pep Jorge @joseplluisjorge Steema Software July 213!"# $ %&# %####' #&() % # # # #&* # ## +, # -. / " - $- * 11 1 1$ 2 11 1 3 4 / $ 5 5,+67 +68$ Copyright 213 Steema Software SL. Copyright Information.
More informationEvents and Exceptions
Events and Exceptions Analysis and Design of Embedded Systems and OO* Object-oriented programming Jan Bendtsen Automation and Control Lecture Outline Exceptions Throwing and catching Exceptions creating
More informationProctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor:
More informationOOP Assignment V. For example, the scrolling text (moving banner) problem without a thread looks like:
OOP Assignment V If we don t use multithreading, or a timer, and update the contents of the applet continuously by calling the repaint() method, the processor has to update frames at a blinding rate. Too
More informationMyDatabaseHelper. public static final String TABLE_NAME = "tbl_bio";
Page 1 of 5 MyDatabaseHelper import android.content.context; import android.database.sqlite.sqliteopenhelper; class MyDatabaseHelper extends SQLiteOpenHelper { private static final String DB_NAME = "friend_db";
More informationProctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor: Alan
More informationpackage As7BattleShip;
package As7BattleShip; Program: BattleshipBoard.java Author: Kevin Nider Date: 11/18/12 Description: Assignment 7: Runs the battleship game Input: ship placement board files and computer player type Output:
More informationCSC 569 WINTER 13 GRADUATE PROJECT: NETWORK-BASED IMAGE REPOSITORY
CSC 569 WINTER 13 GRADUATE PROJECT: NETWORK-BASED IMAGE REPOSITORY PROFESSOR GODFREY MUGANDA 1. Multi-Threaded Network Photo Server You are going to write a system that allows users to store photos on
More informationGoals. Lecture 7 More GUI programming. The application. The application D&D 12. CompSci 230: Semester JFrame subclass: ListOWords
Goals By the end of this lesson, you should: Lecture 7 More GUI programming 1. Be able to write Java s with JTextField, JList, JCheckBox and JRadioButton components 2. Be able to implement a ButtonGroup
More informationMultiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks)
M257 MTA Spring2010 Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks) 1. If we need various objects that are similar in structure, but
More informationChapter 17 Binary I/O. Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
Chapter 17 Binary I/O 1 Motivations Data stored in a text file is represented in human-readable form. Data stored in a binary file is represented in binary form. You cannot read binary files. They are
More informationI/O STREAM (REQUIRED IN THE FINAL)
I/O STREAM (REQUIRED IN THE FINAL) STREAM A stream is a communication channel that a program has with the outside world. It is used to transfer data items in succession. An Input/Output (I/O) Stream represents
More informationFirst Name: AITI 2004: Exam 2 July 19, 2004
First Name: AITI 2004: Exam 2 July 19, 2004 Last Name: JSP Track Read Instructions Carefully! This is a 3 hour closed book exam. No calculators are allowed. Please write clearly if we cannot understand
More informationWeek 12. Streams and File I/O. Overview of Streams and File I/O Text File I/O
Week 12 Streams and File I/O Overview of Streams and File I/O Text File I/O 1 I/O Overview I/O = Input/Output In this context it is input to and output from programs Input can be from keyboard or a file
More informationProgramming with the SCA BB Service Configuration API
CHAPTER 3 Programming with the SCA BB Service Configuration API Published: December 23, 2013, Introduction This chapter is a reference for the main classes and methods of the Cisco SCA BB Service Configuration
More informationProgramming with the SCA BB Service Configuration API
CHAPTER 3 Programming with the SCA BB Service Configuration API Revised: September 17, 2012, Introduction This chapter is a reference for the main classes and methods of the Cisco SCA BB Service Configuration
More informationBasic I/O - Stream. Java.io (stream based IO) Java.nio(Buffer and channel-based IO)
I/O and Scannar Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283 I/O operations Three steps:
More informationProgramming with the SCA BB Service Configuration API
CHAPTER 3 Programming with the SCA BB Service Configuration API Revised: November 8, 2010, Introduction This chapter is a reference for the main classes and methods of the Cisco SCA BB Service Configuration
More informationLAMPIRAN Lampiran Utama. a. Struktur Organisasi
LAMPIRAN 5.1. Lampiran Utama a. Struktur Organisasi b. Flowchart Prosedur Penggajian PT Timatex c. Coding List Class Koneksi package ta_552012010_aprilia; import java.sql.*; public class koneksi { private
More informationFile Operations in Java. File handling in java enables to read data from and write data to files
Description Java Basics File Operations in Java File handling in java enables to read data from and write data to files along with other file manipulation tasks. File operations are present in java.io
More information1993: renamed "Java"; use in a browser instead of a microwave : Sun sues Microsoft multiple times over Java
Java history invented mainly by James Gosling ([formerly] Sun Microsystems) 1990: Oak language for embedded systems needs to be reliable, easy to change, retarget efficiency is secondary implemented as
More informationCPSC 319. Week 2 Java Basics. Xiaoyang Liu & Sorting Algorithms
CPSC 319 Week 2 Java Basics Xiaoyang Liu xiaoyali@ucalgary.ca & Sorting Algorithms Java Basics Variable Declarations Type Size Range boolean 1 bit true, false char 16 bits Unicode characters byte 8 bits
More informationSoftware Practice 1 - File I/O
Software Practice 1 - File I/O Stream I/O Buffered I/O File I/O with exceptions CSV format Practice#6 Prof. Joonwon Lee T.A. Jaehyun Song Jongseok Kim (42) T.A. Sujin Oh Junseong Lee 1 (43) / 38 2 / 38
More informationneeds to be reliable, easy to change, retarget efficiency is secondary implemented as interpreter, with virtual machine
Java history invented mainly by James Gosling ([formerly] Sun Microsystems) 1990: Oak language for embedded systems needs to be reliable, easy to change, retarget efficiency is secondary implemented as
More informationObject-Oriented Programming in the Java language
Object-Oriented Programming in the Java language Part 5. Exceptions. I/O in Java Yevhen Berkunskyi, NUoS eugeny.berkunsky@gmail.com http://www.berkut.mk.ua Exceptions Exceptions in Java are objects. All
More informationDM550 Introduction to Programming part 2. Jan Baumbach.
DM550 Introduction to Programming part 2 Jan Baumbach jan.baumbach@imada.sdu.dk http://www.baumbachlab.net Map ADT: Specification 2 maps work like dictionaries in Python interface Map specifies standard
More informationCSE 143 Lecture 25. I/O Streams; Exceptions; Inheritance. read 9.3, 6.4. slides adapted from Marty Stepp
CSE 143 Lecture 25 I/O Streams; Exceptions; Inheritance read 9.3, 6.4 slides adapted from Marty Stepp http://www.cs.washington.edu/143/ Input and output streams stream: an abstraction of a source or target
More informationPlaniSphere. Creating a plug-in for PlaniSphere.
Creating a plug-in for PlaniSphere Creating a plug-in requires a developer to implement SpatialPlugin and SpatialPluginFrame interfaces (see Figure 1). The SpatialPlugin interface defines methods that
More informationCSE 143 Lecture 21. I/O Streams; Exceptions; Inheritance. read 9.3, 6.4. slides created by Marty Stepp
CSE 143 Lecture 21 I/O Streams; Exceptions; Inheritance read 9.3, 6.4 slides created by Marty Stepp http://www.cs.washington.edu/143/ Input and output streams stream: an abstraction of a source or target
More informationCSE 143 Lecture 22. I/O Streams; Exceptions; Inheritance. read 9.3, 6.4. slides created by Marty Stepp
CSE 143 Lecture 22 I/O Streams; Exceptions; Inheritance read 9.3, 6.4 slides created by Marty Stepp http://www.cs.washington.edu/143/ Input and output streams stream: an abstraction of a source or target
More informationFinal Exam. CSC 121 Fall Lecturer: Howard Rosenthal. Dec. 13, 2017
Your Name: Final Exam. CSC 121 Fall 2017 Lecturer: Howard Rosenthal Dec. 13, 2017 The following questions (or parts of questions) in numbers 1-17 are all worth 2 points each. The programs have indicated
More information输 入输出相关类图. DataInput. DataOutput. java.lang.object. FileInputStream. FilterInputStream. FilterInputStream. FileOutputStream
输 入 / 输出 杨亮 流的分类 输 入输出相关类图 OutputStream FileOutputStream DataInputStream ObjectOutputStream FilterInputStream PipedOutputStream DataOutput InputStream DataInputStream PrintStream ObjectInputStream PipedInputStream
More informationFile Input and Output Review CSC 123 Fall 2018 Howard Rosenthal
File Input and Output Review CSC 123 Fall 218 Howard Rosenthal Lesson Goals The File Class creating a File object Review FileWriter for appending to files Creating a Scanner object to read from a File
More informationCS1092: Tutorial Sheet: No 3 Exceptions and Files. Tutor s Guide
CS1092: Tutorial Sheet: No 3 Exceptions and Files Tutor s Guide Preliminary This tutorial sheet requires that you ve read Chapter 15 on Exceptions (CS1081 lectured material), and followed the recent CS1092
More information17 GUI API: Container 18 Hello world with a GUI 19 GUI API: JLabel 20 GUI API: Container: add() 21 Hello world with a GUI 22 GUI API: JFrame: setdefau
List of Slides 1 Title 2 Chapter 13: Graphical user interfaces 3 Chapter aims 4 Section 2: Example:Hello world with a GUI 5 Aim 6 Hello world with a GUI 7 Hello world with a GUI 8 Package: java.awt and
More informationCS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University
CS5000: Foundations of Programming Mingon Kang, PhD Computer Science, Kennesaw State University Files Two types: Text file and Binary file Text file (ASCII file) The file data contains only ASCII values
More informationGenerating Charts in PDF Format with JFreeChart and itext
Generating Charts in PDF Format with JFreeChart and itext Written by David Gilbert May 28, 2002 c 2002, Simba Management Limited. All rights reserved. Everyone is permitted to copy and distribute verbatim
More informationIT101. File Input and Output
IT101 File Input and Output IO Streams A stream is a communication channel that a program has with the outside world. It is used to transfer data items in succession. An Input/Output (I/O) Stream represents
More informationCOMP 213. Advanced Object-oriented Programming. Lecture 19. Input/Output
COMP 213 Advanced Object-oriented Programming Lecture 19 Input/Output Input and Output A program that read no input and produced no output would be a very uninteresting and useless thing. Forms of input/output
More informationFirst Name: AITI 2004: Exam 2 July 19, 2004
First Name: AITI 2004: Exam 2 July 19, 2004 Last Name: Standard Track Read Instructions Carefully! This is a 3 hour closed book exam. No calculators are allowed. Please write clearly if we cannot understand
More information1D/2D android secondary development
1D/2D android secondary development The example in this document is developed in eclipse. 1. Import library to project Copy the filefolder and to the Project- libs 2.Copy JAVA
More informationCPIT 305 Advanced Programming
M. G. Abbas Malik CPIT 305 Advanced Programming mgmalik@uj.edu.sa Assistant Professor Faculty of Computing and IT University of Jeddah Advanced Programming Course book: Introduction to Java Programming:
More informationProctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC124, WINTER TERM, 2009 FINAL EXAMINATION 7pm to 10pm, 18 APRIL 2009, Dunning Hall Instructor: Alan McLeod If the
More informationAnimatedImage.java. Page 1
1 import javax.swing.japplet; 2 import javax.swing.jbutton; 3 import javax.swing.jpanel; 4 import javax.swing.jcombobox; 5 import javax.swing.jlabel; 6 import javax.swing.imageicon; 7 import javax.swing.swingutilities;
More informationFiles and IO, Streams. JAVA Standard Edition
Files and IO, Streams JAVA Standard Edition Java - Files and I/O The java.io package contains nearly every class you might ever need to perform input and output (I/O) in Java. All these streams represent
More informationתוכנה 1 תרגול 8 קלט/פלט רובי בוים ומתי שמרת
תוכנה 1 תרגול 8 קלט/פלט רובי בוים ומתי שמרת A Typical Program Most applications need to process some input and produce some output based on that input The Java IO package (java.io) is to make that possible
More informationJava Exception. Wang Yang
Java Exception Wang Yang wyang@njnet.edu.cn Last Chapter Review A Notion of Exception Java Exceptions Exception Handling How to Use Exception User-defined Exceptions Last Chapter Review Last Chapter Review
More informationCSPP : Introduction to Object-Oriented Programming
CSPP 511-01: Introduction to Object-Oriented Programming Harri Hakula Ryerson 256, tel. 773-702-8584 hhakula@cs.uchicago.edu August 7, 2000 CSPP 511-01: Lecture 15, August 7, 2000 1 Exceptions Files: Text
More informationAPPENDIX. public void cekroot() { System.out.println("nilai root : "+root.data); }
APPENDIX CLASS NODE AS TREE OBJECT public class Node public int data; public Node left; public Node right; public Node parent; public Node(int i) data=i; PROCEDURE BUILDING TREE public class Tree public
More informationPage 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
Page 1 of 16 SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2005 FINAL EXAMINATION 9am to 12noon, 19 DECEMBER 2005 Instructor: Alan McLeod
More informationPrinciples of Software Construction: Objects, Design and Concurrency. Design Case Study: Stream I/O. toad
Principles of Software Construction: Objects, Design and Concurrency Design Case Study: Stream I/O 15-214 toad Christian Kästner Charlie Garrod School of Computer Science 2014 C Kästner, C Garrod, J Aldrich,
More informationTools : The Java Compiler. The Java Interpreter. The Java Debugger
Tools : The Java Compiler javac [ options ] filename.java... -depend: Causes recompilation of class files on which the source files given as command line arguments recursively depend. -O: Optimizes code,
More informationCPSC 441 Tutorial TCP Server. Department of Computer Science University of Calgary
CPSC 441 Tutorial TCP Server Department of Computer Science University of Calgary TCP Socket Client Server Connection Request Server Listening on welcoming socket Client Socket Server Socket Data Simple
More informationOracle NoSQL Database. Large Object API. 12c Release 1
Oracle NoSQL Database Large Object API 12c Release 1 (Library Version 12.1.3.0) Legal Notice Copyright 2011, 2012, 2013, 2014, Oracle and/or its affiliates. All rights reserved. This software and related
More informationProctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC124, WINTER TERM, 2009 FINAL EXAMINATION 7pm to 10pm, 18 APRIL 2009, Dunning Hall Instructor: Alan McLeod
More informationFile I/O Introduction to File I/O Text Files The File Class Binary Files 614
10.1 Introduction to File I/O 574 Streams 575 Text Files and Binary Files 575 10.2 Text Files 576 Writing to a Text File 576 Appending to a Text File 583 Reading from a Text File 586 Reading a Text File
More informationZipping Files Using Java by Julian Robichaux, panagenda originally published on socialbizug.org, July 2012
Zipping Files Using Java by Julian Robichaux, panagenda originally published on socialbizug.org, July 2012 Sometimes it is convenient to generate a zip file programmatically. Perhaps you want to email
More informationExample: Copying the contents of a file
Administrivia Assignment #4 is due imminently Due Thursday April 8, 10:00pm no late assignments will be accepted Sign up in the front office for a demo time Dining Philosophers code is online www.cs.ubc.ca/~norm/211/2009w2/index.html
More informationCSCI 201L Midterm Written Summer % of course grade
CSCI 201L Summer 2016 10% of course grade 1. Abstract Classes and Interfaces Give two differences between an interface and an abstract class in which all of the methods are abstract. (0.5% + 0.5%) 2. Serialization
More information1.00 Lecture 30. Sending information to a Java program
1.00 Lecture 30 Input/Output Introduction to Streams Reading for next time: Big Java 15.5-15.7 Sending information to a Java program So far: use a GUI limited to specific interaction with user sometimes
More information