Pananaliksik Tungkol Sa Dota

Topics: Class, File format, Byte Pages: 5 (627 words) Published: October 23, 2012
JConverter is a simple program for people who wants to convert any files to Java Array Format. PURPOSE:
This application enables you to convert file/s to a Java Array Format. With just a minute, your file/s (images, sounds, video, etc.) are now converted. CODE:
import java.text.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class JConverter extends JFrame{
private Container container = getContentPane();
private JProgressBar progressBar = new JProgressBar();
private JFileChooser chooser = chooser = new JFileChooser(); private JMenuBar bar = new JMenuBar();
private JMenu menuFile = new JMenu("File");
private JMenuItem menuConvertFile = new JMenuItem("Convert File"); private JMenuItem menuExit = new JMenuItem("Exit");
private JMenu menuHelp = new JMenu("Help");
private JMenuItem menuSite = new JMenuItem("Visit web site"); private JMenuItem menuAbout = new JMenuItem("About");
private JPanel panel = new JPanel();
private JLabel labelNameOfArray = new JLabel("Array name"); private JTextField nameOfArray = new JTextField(10);
private JLabel labelBytesPerLine = new JLabel("How many bytes per line"); private JTextField bytesPerLine = new JTextField(3);

private class PerformFile extends Thread{
public void run(){
File theOpenedFile=null;
FileInputStream in;
FileOutputStream out;
int resultOfChoice;
int readFromFileResult;
int maxColomnCount;
byte fileReadArray[];
int openedFileLength=0;

chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); resultOfChoice = chooser.showOpenDialog(null);
theOpenedFile = chooser.getSelectedFile();
if (resultOfChoice==chooser.CANCEL_OPTION) return;
if (!(theOpenedFile==null||theOpenedFile.getName().equals(""))){ try{
in = new FileInputStream(theOpenedFile.getPath()); menuConvertFile.setEnabled(false);
out = new FileOutputStream(theOpenedFile.getPath() + ".j"); openedFileLength = (int)theOpenedFile.length();
out.write(' '); out.write(' ');
out.write('b'); out.write('y'); out.write('t'); out.write('e'); out.write(' '); for (int i=0;i<nameOfArray.getText().length();i++) out.write(nameOfArray.getText().charAt(i)); out.write('['); out.write(']'); out.write('='); out.write('{'); out.write(13); out.write(10); out.write(' '); out.write(' '); out.write(' '); out.write(' '); fileReadArray = new byte[openedFileLength];

readFromFileResult =;

maxColomnCount = Integer.parseInt(bytesPerLine.getText()); if (maxColomnCount<10) maxColomnCount=10;
if (maxColomnCount>1000) maxColomnCount=1000; }
catch(NumberFormatException e){maxColomnCount=20;} bytesPerLine.setText(""+maxColomnCount);

for (int i=0;i<openedFileLength;i++){
if (i>0) out.write(',');
if (i % maxColomnCount == (maxColomnCount-1)){
out.write(13); out.write(10); out.write(' '); out.write(' '); out.write(' '); out.write(' '); }
out.write(Byte.toString(fileReadArray[i]).charAt(0)); out.write(Byte.toString(fileReadArray[i]).charAt(1)); out.write(Byte.toString(fileReadArray[i]).charAt(2)); out.write(Byte.toString(fileReadArray[i]).charAt(3)); } catch(StringIndexOutOfBoundsException e){}

progressBar.setString(""+((i+1)*100/openedFileLength)+"%"); progressBar.setStringPainted(true);

Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Pananaliksik at Panimula Tungkol Sa Droga Essay
  • Pananaliksik Sa Filipino Essay
  • Tula Tungkol Sa Pagkakaibigan Essay
  • Pananaliksik Sa Filipino 2 Essay
  • Essay about talumpati tungkol sa kalikasan
  • Tesis Tungkol Sa Kahirapan Essay
  • Dota Essay
  • Essay about impormasyon tungkol sa silangang asia

Become a StudyMode Member

Sign Up - It's Free