Help on reading and writing to a file !!!!!!!!!!!!!!!!
hi there
anyone can help me on how to write and read from a file? how can i read one string at a time instead of a char. thank you.
Use the StringTokenizer to break up the line
File newFile = new File("text.txt");
BufferedReader in = new BufferedReader(new FileReader (newFile));
String line;
while((line = in.readLine()) != null){
StringTokenizer st = new StringTokenizer(inputLine, " ");
while(st.hasMoreTokens()){
// do something with the token
// e.g:
// String lc = st.nextToken().toLowerCase()
hope that helps
Similar Messages
-
Need Help: UTL_FILE Reading and Writing to Text File
Hello I am using version 11gR2 using the UTL_FILE function to read from a text file then write the lines where it begins with word 'foo' and end my writing to the text file where the line with the word 'ZEN' is found. Now, I have several lines that begin with 'foo' and 'ZEN' Which make for one full paragraph, and in this paragraph there's a line that begins with 'DE4.2'. Therefore,
I need to write all paragraphs that include the line 'DE4.2' in their beginning and ending lines 'foo' and 'ZEN'
FOR EXAMPLE:
FOO/234E53LLID
THIS IS MY SECOND LINE
THIS IS MY THIRD LINE
DE4.2 THIS IS MY FOURTH LINE
THIS IS MY FIFTH LINE
ZEN/DING3434343
FOO/234E53LLID
THIS IS MY SECOND LINE
THIS IS MY THIRD LINE
THIS IS MY FIFTH LINE
ZEN/DING3434343
I am only interested in writing the first paragraph tha includes line DE4.2 in one of ther lines Not the Second paragraph that does not include the 'DE4.2'
Here's my code thus far:
CREATE OR REPLACE PROCEDURE my_app2 IS
infile utl_file.file_type;
outfile utl_file.file_type;
buffer VARCHAR2(30000);
b_paragraph_started BOOLEAN := FALSE; -- flag to indicate that required paragraph is started
BEGIN
-- open a file to read
infile := utl_file.fopen('TEST_DIR', 'mytst.txt', 'r');
-- open a file to write
outfile := utl_file.fopen('TEST_DIR', 'out.txt', 'w');
-- check file is opened
IF utl_file.is_open(infile)
THEN
-- loop lines in the file
LOOP
BEGIN
utl_file.get_line(infile, buffer);
--BEGINPOINT APPLICATION
IF buffer LIKE 'foo%' THEN
b_paragraph_started := TRUE;
END IF;
--LOOK FOR GRADS APPS
IF b_paragraph_started AND buffer LIKE '%DE4%' THEN
utl_file.put_line(outfile,buffer, FALSE);
END IF;
--ENDPOINT APPLICATION
IF buffer LIKE 'ZEN%' THEN
b_paragraph_started := FALSE;
END IF;
utl_file.fflush(outfile);
EXCEPTION
WHEN no_data_found THEN
EXIT;
END;
END LOOP;
END IF;
utl_file.fclose(infile);
utl_file.fclose(outfile);
EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20099, 'Unknown UTL_FILE Error');
END my_app2;
When I run this code I only get one line: DE4.2 I AM MISSING THE ENTIRE PARAGRAPH
PLEASE ADVISE...Hi,
Look at where you're calling utl_file.put_line. The only time you're writing anything is immediately after you find the the key word 'DE4', and then you're writing just that line.
You need to store the entire paragraph, and when you reach the end of the paragraph, write the whole thing only if you found the key word, like this:
CREATE OR REPLACE PROCEDURE my_app2 IS
TYPE line_collection
IS TABLE OF VARCHAR2 (30000)
INDEX BY BINARY_INTEGER;
infile utl_file.file_type;
outfile utl_file.file_type;
input_paragraph line_collection;
input_paragraph_cnt PLS_INTEGER := 0; -- Number of lines stored in input_paragraph
b_paragraph_started BOOLEAN := FALSE; -- flag to indicate that required paragraph is started
found_key_word BOOLEAN := FALSE; -- Does this paragraph contain the magic word?
BEGIN
-- open a file to read
infile := utl_file.fopen('TEST_DIR', 'mytst.txt', 'r');
-- open a file to write
outfile := utl_file.fopen('TEST_DIR', 'out.txt', 'w');
-- check file is opened
IF utl_file.is_open(infile)
THEN
-- loop lines in the file
LOOP
BEGIN
input_paragraph_cnt := input_paragraph_cnt + 1;
utl_file.get_line (infile, input_paragraph (input_paragraph_cnt));
--BEGINPOINT APPLICATION
IF LOWER (input_paragraph (input_paragraph_cnt)) LIKE 'foo%' THEN
b_paragraph_started := TRUE;
END IF;
--LOOK FOR GRADS APPS
IF b_paragraph_started
THEN
IF input_paragraph (input_paragraph_cnt) LIKE '%DE4%'
THEN
found_key_word := TRUE;
END IF;
--ENDPOINT APPLICATION
IF input_paragraph (input_paragraph_cnt) LIKE 'ZEN%' THEN
b_paragraph_started := FALSE;
IF found_key_word
THEN
FOR j IN 1 .. input_paragraph_cnt
LOOP
utl_file.put_line (outfile, input_paragraph (j), FALSE);
END LOOP;
END IF;
found_key_word := FALSE;
input_paragraph_cnt := 0;
END IF;
ELSE -- paragraph is not started
input_paragraph_cnt := 0;
END IF;
EXCEPTION
WHEN no_data_found THEN
EXIT;
END;
END LOOP;
END IF;
utl_file.fclose (infile);
utl_file.fclose (outfile);
--EXCEPTION
-- WHEN OTHERS THEN
-- raise_application_error(-20099, 'Unknown UTL_FILE Error');
END my_app2;
SHOW ERRORSIf you don't have an EXCEPTION section, the default error handling will print an error message, spcifying exactly what the error was, and which line of your code caused the error. By using your own EXCEPTION section, you're hiding all that information. I admit, the error messages aren't always as informative as we'd like, but they're never less informative than "Unknown UTL_FILE Error'. Don't use your own EXCEPTION handling unless you can improve on the default.
Remember that anything inside quotes is case-sensitive. If your file contains upper-case 'FOO', then it won't be "LIKE 'foo%' ".
Edited by: Frank Kulash on Dec 7, 2011 1:35 PM
You may have noticed that this site normally doesn't display multiple spaces in a row.
Whenever you post formatted text (such as your code) on this site, type these 6 characters:
\{code}
(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing. -
Reading and writing from a file
I am trying to read and write to a file so that I may store an array of string and a double in my application, but I have come upon a couple of problems; first when I put my file path into the path constant it will say that the file is not there ever though it is (so I have to force the issue and when the application asks for a file I have to browse and add the files), secondly when I run the program and it reads from the file it does not display the strings or doubles immediately instead I have to hit the submit button and than they finally come up, thirdly when I reset my values in the .txt files and put in my string and double and hit submit the array jumps one spot and starts at the index of 1 (array[1]) if anyone can help I would appreciate it a lot.
here is my code:
Harold Timmis
[email protected]
Orlando,Fl
*Kudos always welcome
Solved!
Go to Solution.
Attachments:
testingfileIO.vi 30 KB
double.txt 1 KB
string.txt 1 KBHarold Timmis wrote:
I am trying to read and write to a file so that I may store an array of string and a double in my application, but I have come upon a couple of problems; first when I put my file path into the path constant it will say that the file is not there ever though it is (so I have to force the issue and when the application asks for a file I have to browse and add the files),
I don't see that behavior at all about forcing the issue. Why are you using Not a Path constants? Why not turn those constants into controls you put on your front panel?
secondly when I run the program and it reads from the file it does not display the strings or doubles immediately instead I have to hit the submit button and than they finally come up,
Put your array indicators before your event structure rather than after. Think dataflow. The code pauses at the event structure waiting for an even to fire. Only when it does (such as hitting the submit button) does the data get written to the array indicators.
thirdly when I reset my values in the .txt files and put in my string and double and hit submit the array jumps one spot and starts at the index of 1 (array[1]) if anyone can help I would appreciate it a lot.
I don't see this behavior either. How come your double.txt file has names in it, and your string.txt file has doubles in it? -
Reading and Writing large Excel file using JExcel API
hi,
I am using JExcelAPI for reading and writing excel file. My problem is when I read file with 10000 records and 95 columns (file size about 14MB), I got out of memory error and application is crashed. Can anyone tell me is there any way that I can read large file using JExcelAPI throug streams or in any other way. Jakarta POI is also showing this behaviour.
Thanks and advanceSorry when out of memory error is occurred no stack trace is printed as application is crashed. But I will quote some lines taken from JProfiler where this problem is occurred:
reader = new FileInputStream(new File(filePath));
workbook = Workbook.getWorkbook(reader);
*sheeet = workbook.getSheet(0);* // here out of memory error is occured
JProfiler tree:
jxl.Workbook.getWorkBook
jxl.read.biff.File
jxl.read.biff.CompoundFile.getStream
jxl.read.biff.CompoundFile.getBigBlockStream Thanks -
Very slow painting while reading and writing doubles into file
for 15MB length file i = 7662080
for 50MB length file i = 12414368
Part of Code for writing into file follows like this:
try{
fos = new FileOutputStream("Angel.txt");
File f = new File("Angel.txt");
if(f.length() >=4)
f.delete();
fos = new FileOutputStream("Angel.txt");
dos = new DataOutputStream(new BufferedOutputStream(fos,1000000));
int x=0;
double y_last, y_new;
for(int j=0 ;j<i ;j++)
if(some condition)
y_new = ....;
try{
//previously in vectors
y_last = y_new;
vect.add(new Line2D.Double(x, y_last, x, y_new)_;
dos.writeDouble(y_new);
}catch(Exception e){System.out.println(e);}
dos.close();
fos.close();
x++;
}catch(Exception excp){System.out.println(excp);}
part of code for reading from file follows like this:
public void paint(Graphics g)
try{
double y1, y2 =0;
Line2D.Double doub;
raf = new RandomAccessFile("Angel.txt","r");
dis = new DataInputStream(new BufferedInputStream(new FileInputStream(raf.getFD(),1000000)));
raf.seek((rect.x*8));
for (int i = 0/any value; (i < value as per choice); i++)
g2.setStroke(new BasicStroke(0)); //2
y1 = y2;
y2 =dis.readDouble();
doub=new Line2D.Double(i,y1,i,y2);
g2.draw(doub);
dis.close();
raf.close();
}catch(Exception excp){System.out.println(excp);}
I tried using Object Streams but NotSerializable Exception is thrown as Line2D.Double objects
are not serialized.
Any idea to make reading and writing into file specially from MB files faster is appreciated.Why are you reading in the file in the paint method ?
Create your data once before painting.
I think you should explain what is your goal and what behavior you want.
Denis -
Reading and writing non-English files
Hi there..
I wonder if anyone can tell me how to read and write non-English language files like French or Arabic files...
Im also interested in knowing how can i convert from Unicode to ASCII and vice versa..
thanx.. Mouradhi there ..
thanx for ur cooperation .. but actually i have tried the following code and it didnt work; so, im looking for more help :)
esp. if there are any notes about the files themselves for example;
by the way i used Notepad files in unicode format..
my code is :
import java.io.*;
public class MainClass {
public static void main(String args[]){
String inputfile = "arabic.txt";
String outfile = "outfile.txt";
try{
RandomAccessFile raf = new RandomAccessFile(inputfile, "r");
InputStreamReader isr = new InputStreamReader(
new FileInputStream(inputfile), "Cp1256");
OutputStreamWriter osw = new OutputStreamWriter(
new FileOutputStream(outfile), "Cp1256");
for(int i=0; i<raf.length(); i++)
osw.write(isr.read());
osw.close();
}catch(UnsupportedEncodingException uee){
System.out.println("UEException: "+ uee.getMessage());
}catch(FileNotFoundException fnfe){
System.out.println("FNFException: "+ fnfe.getMessage());
}catch(IOException ioe){
System.out.println("IOException: "+ ioe.getMessage());
thanx again..Mourad -
READING AND WRITING FROM A FILE(WRITTEN IN ANOTHER LANGUAGE)
# Comment
INTEGER Declares integer type variable
STRING Declares string type variable
LET Assigns a variable
CALCULATE Performs an arithmetic calculation
PRINT Writes data to the console
PRINTLN As print, but followed by a new line
END Terminates the program
Each line of the program must begin with one of these words, and the language should not be case sensitive.
Tim Brailsford, 2007
G64ICP
COMMENT
Any line beginning with the # character is completely ignored.
Example:
# ignore this line!
INTEGER
The INTEGER reserved word declares an Integer variable, and assigns a default value of 0 to it.
Example:
INTEGER myInt
This example is equivalent to the Java statment "int myInt=0;"
STRING
The STRING reserved word declares a String variable, and assigns an empty string to it.
Example:
STRING myString
This is equivalent to the Java statement "String myString;"
LET
This assigns values to variables (either integers, or strings enclosed
in double quotes).
Examples:
LET myInt=42
LET myString="Hello World!"
CALCULATE
This performs numeric calculations upon values or variables, and assigns the result to a variable (which must have
been declared earlier). Four operators are supported: + *
and / (for addition, subtraction multiplication and
integer division respectively).
Examples:
CALCULATE myInt=2*2
CALCULATE myInt=myInt+24
CALCULATE myInt=intA/intB
PRINT and PRINTLN
These words both print to the console the
only difference being that PRINTLN appends a new line (as does
System.out.println in Java). These can print either text provided as an argument, or variables (string or integer).
Examples:
PRINTLN "Hello World!"
PRINT myString
PRINTLN myInt
END
This terminates the program, and prints a message to that effect.
TPL Example
To the left is an example TPL input file , to
calculate the factorial of 5. This should produce
an output similar to that shown overleaf (except
that calculates the factorial of 10).
# A TPL Program to calculate the factorial of 5
INTEGER myInt
INTEGER factorial
STRING myString
LET mystring="Factorial Program"
LET myInt=5
CALCULATE factorial=myInt*4
CALCULATE factorial=factorial*3
CALCULATE factorial=factorial*2
Tim Brailsford, 2007
G64ICP
PRINTLN mystring
PRINTLN
PRINT "The factorial of "
PRINT myInt
PRINT " is "
PRINTLN factorial
END
Documentation
Document your code by writing instructions explaining how to run it, listing all of the files you have submitted,
and specifying any limitations (eg you might want to say what platforms you would expect it to run on, and what
platforms you have tested it on). This document should be written as a plain text file (ie ASCII � MS Word binary
files are not acceptable) � and this file should be called README.TXT. This file should constitute the user
manual of your program, and should explain exactly how to use your program.
The README file should be the user manual for your language as implemented.
NB:
I want it to read values from the file as given above and execute the answer in the command prompt( as intented in the file above)
Thanks
Alam IkennaHai I have one doubt in doing other peoples homework for them. Why bother?
-
Issue with Reading and Writing to a File
Hello all,
I'm having trouble when I run the following example;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.IOException;
public class ReadWriteTextFile {
private static void doReadWriteTextFile() {
try {
// input/output file names
String inputFileName = "README_InputFile.txt";
String outputFileName = "ReadWriteTextFile.out";
// Create FileReader Object
FileReader inputFileReader = new FileReader(inputFileName);
FileWriter outputFileReader = new FileWriter(outputFileName);
// Create Buffered/PrintWriter Objects
BufferedReader inputStream = new BufferedReader(inputFileReader);
PrintWriter outputStream = new PrintWriter(outputFileReader);
outputStream.println("+---------- Testing output to a file ----------+");
outputStream.println();
String inLine = null;
while ((inLine = inputStream.readLine()) != null) {
outputStream.println(inLine);
outputStream.println();
outputStream.println("+---------- Testing output to a file ----------+");
outputStream.close();
inputStream.close();
} catch (IOException e) {
System.out.println("IOException:");
e.printStackTrace();
public static void main(String[] args) {
doReadWriteTextFile();
}Im getting the error
java.io.FileNotFoundException: README_InputFile.txt (The system cannot find the file specified)However the file README_InputFile.txt is definately in the same folder as the class file. So why is this not working?
Any help would be greatly appreciated.
JazSorry you've lost me. All I get are error messages
when I try to compile that statement. What am I
missing?I don't know, it should work:
import java.io.*;
public class Test {
public static void main(String[] args) throws
IOException {
System.out.println(new
File(".").getCanonicalPath());
Sorry I forgot to add the "throws IOException" bit. It works and told me that the path is;
C:\Documents and Settings\Jaz\workspace\Tutorial
I've amended the code so it now looks like this;
String inputFileName = "C:/Documents and Settings/Jaz/workspace/TutorialREADME_InputFile.out";
String outputFileName = "C:/Documents and Settings/Jaz/workspace/TutorialReadWriteTextFile.out";but I still get the error below even though the files are present in that directory;
IOException:
java.io.FileNotFoundException: C:\Documents and Settings\Jaz\workspace\TutorialREADME_InputFile.out (The system cannot find the file specified) -
Reading and writing u16 binary file to a new file
Hello all,
a very simple thing that I just don't seem to be able to figure out. I have a file containing 1024bytes of unsigned 16bit words. I can read it successfully with the right value being displayed. But then I try to write these values to a new file, I can no longer read the same value (in fact it's all grayed out 0) from the newly written file. The newly written file has the right size 1024 bytes, but I don't seem to obtain the right information. I made sure the endian are the same, little-endian.
Attached is my basic VI, and the .dat file is the file containing the binary information.
I'm not using copy file because once I get this figure out, I'll need to append more of the Scan.dat file to one single file.
Thank you!
Solved!
Go to Solution.
Attachments:
read_write_binary_u16.zip 11 KBI would put some wait time between the write and the read. It may be a good idea to actually close the file in between.
I have a feeling that you may not have allowed enough time to actually have the file written out before you read it again. That or since it is still open, the file pointer is at the end of the file and you are trying to read all the bytes starting at the end, which means you get nothing.
Not sure of the exact issue, but those two things comes to mind. -
UTL_FILE: Reading and Writing client-side Files
Hi All,
Please tell me how to read & write UTL_FILE at client-side
RegardsAnd you need this XML to be generated on and read from a client machine? You can't generate the file on the server, move it to the new server, and import it?
If you need to generate files on the client machine, the client application would have to do the file I/O. Java has a number of libraries for generating XML and parsing XML that could be used, for example, but that implies that a Java application has been deployed to the client machine.
Justin -
Problem on reading and writing from from a *.txt file
I get Problem on reading and writing from from a *.txt file. The following is the read() method...
The software said the DataInputStream is depreciated. Can anyone help me please?
public void read()
File file = new File("C://Documents and Settings//Charles//My Documents//Brunel//EE2065//Assignment and Lab//Assignment 4 and Lab 4//data.txt");
FileInputStream in = null;
String str = "";
try
in = new BufferedReader(file);
//in = new FileInputStream(file);
for(;;)
str = new BufferedReader(in).readLine();
//str = new DataInputStream(in).readLine();
if(str == null)
break;
System.out.print(str);
in.close();
catch(IOException e)
System.err.println("execution error: " +e);
}Thank you for your reply. I have made some change. However, there is an incompetable type found error.
in = new BufferedReader(new InputStreamReader(in));The following are all of the code.
public void read()
File file = new File("C://Documents and Settings//Charles//My Documents//Brunel//EE2065//Assignment and Lab//Assignment 4 and Lab 4//data.txt");
FileInputStream in = null;
//BufferedReader in = null;
String str = "";
try
in = new BufferedReader(new InputStreamReader(in));
//in = new FileInputStream(file);
for(;;)
BufferedReader Bstr = new BufferedReader(new InputStreamReader(in));
//str = new BufferedReader(in).readLine();
//str = new DataInputStream(in).readLine();
if(str == null)
break;
System.out.print(str);
in.close();
catch(IOException e)
System.err.println("execution error: " +e); -
Reading and writing to and from a file to a form
Hi there
I would like somebody to send me a code example,
showing me how to reading records from a file to a form,
and writing records to the same file from the same form.
I know that I have to use sycronize, but I just have not been
successful. I can constract forms, go from form to a form,
do buttons, do text fields. I can even read and write from and
to files. However I cannot do is write from a file to a form and
from a form to a file.
could somebody please explain how this done, and could you
please give me a code example. All the books seem to either
deal with forms or with files. None seem to combine both.
I am sure it is very ease to do if ONLY I knew how!!!
thank you very much in advance for you help.I understand that code and I have used it before, however thanks for
trying to help me, it is really appreciated. However, that is not my
problem. I can read and write from a file to the console and vice versa.
what I cannot do, no matter how hard I try, is to write from a file, and
output it in.
I will tell you how far I have got.
I have a MenuFrame class, this is the code for it:
package WorkflowApp;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
public class MenuFrame extends JFrame {
JMenuBar menuBar1 = new JMenuBar();
JMenu menuFile = new JMenu();
JMenuItem menuFileExit = new JMenuItem();
JMenu menuHelp = new JMenu();
JMenuItem menuHelpAbout = new JMenuItem();
JToolBar toolBar = new JToolBar();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JButton jButton3 = new JButton();
ImageIcon image1;
ImageIcon image2;
ImageIcon image3;
JLabel statusBar = new JLabel();
Button button2 = new Button();
Button button3 = new Button();
Button button4 = new Button();
Button button5 = new Button();
Button button6 = new Button();
Button button7 = new Button();
Button button1 = new Button();
//Construct the frame
public MenuFrame() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
catch(Exception e) {
e.printStackTrace();
//Component initialization
private void jbInit() throws Exception {
image1 = new ImageIcon(WorkflowApp.MenuFrame.class.getResource("openFile.gif"));
image2 = new ImageIcon(WorkflowApp.MenuFrame.class.getResource("closeFile.gif"));
image3 = new ImageIcon(WorkflowApp.MenuFrame.class.getResource("help.gif"));
this.getContentPane().setLayout(null);
this.setSize(new Dimension(400, 492));
this.setTitle("MenuFrame");
statusBar.setText(" ");
statusBar.setBounds(new Rectangle(0, 0, 3, 17));
menuFile.setText("File");
menuFileExit.setText("Exit");
menuFileExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
fileExit_actionPerformed(e);
menuHelp.setText("Help");
menuHelpAbout.setText("About");
menuHelpAbout.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
helpAbout_actionPerformed(e);
jButton1.setIcon(image1);
jButton1.setToolTipText("Open File");
jButton2.setIcon(image2);
jButton2.setToolTipText("Close File");
jButton3.setIcon(image3);
jButton3.setToolTipText("Help");
toolBar.setBorder(null);
toolBar.setBounds(new Rectangle(2, 2, 389, 30));
button2.setBounds(new Rectangle(217, 62, 135, 44));
button2.setLabel("Staff Details");
button2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button2_actionPerformed(e);
button3.setBounds(new Rectangle(26, 127, 135, 44));
button3.setLabel("Arange Viewing");
button3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button3_actionPerformed(e);
button4.setBounds(new Rectangle(218, 127, 136, 41));
button4.setLabel("Valuation");
button4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button4_actionPerformed(e);
button5.setBounds(new Rectangle(28, 196, 135, 41));
button5.setLabel("Schedule");
button6.setBounds(new Rectangle(221, 194, 133, 40));
button6.setName("button6");
button6.setLabel("Register Interest");
button7.setBounds(new Rectangle(31, 266, 133, 42));
button7.setLabel("Register Offers");
button1.setBounds(new Rectangle(27, 62, 131, 42));
button1.setLabel("New Client");
button1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button1_actionPerformed(e);
menuFile.add(menuFileExit);
menuHelp.add(menuHelpAbout);
menuBar1.add(menuFile);
menuBar1.add(menuHelp);
this.setJMenuBar(menuBar1);
this.getContentPane().add(statusBar, null);
this.getContentPane().add(toolBar, null);
toolBar.add(jButton1);
toolBar.add(jButton2, null);
toolBar.add(jButton3, null);
this.getContentPane().add(button3, null);
this.getContentPane().add(button5, null);
this.getContentPane().add(button7, null);
this.getContentPane().add(button2, null);
this.getContentPane().add(button4, null);
this.getContentPane().add(button6, null);
this.getContentPane().add(button1, null);
//File | Exit action performed
public void fileExit_actionPerformed(ActionEvent e) {
System.exit(0);
//Help | About action performed
public void helpAbout_actionPerformed(ActionEvent e) {
MenuFrame_AboutBox dlg = new MenuFrame_AboutBox(this);
Dimension dlgSize = dlg.getPreferredSize();
Dimension frmSize = getSize();
Point loc = getLocation();
dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
dlg.setModal(true);
dlg.show();
//Overridden so we can exit on System Close
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if(e.getID() == WindowEvent.WINDOW_CLOSING) {
fileExit_actionPerformed(null);
void button2_actionPerformed(ActionEvent e) {
StaffDetails myFrame = new StaffDetails();
myFrame.show();
void button3_actionPerformed(ActionEvent e) {
ArrangeViewing myFrame = new ArrangeViewing();
myFrame.show();
void button1_actionPerformed(ActionEvent e) {
NewClientFrame myFrame = new NewClientFrame();
myFrame.show();
// System.exit(1);
void button4_actionPerformed(ActionEvent e) {
Valuation myFrame = new Valuation();
myFrame.show();
then I have a new form class, this is the code for it
package WorkflowApp;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class NewClientFrame extends JFrame {
Label label1 = new Label();
Label label2 = new Label();
Label label3 = new Label();
Label label4 = new Label();
Label label5 = new Label();
Label label6 = new Label();
Label label7 = new Label();
Label label8 = new Label();
Label label9 = new Label();
Label label10 = new Label();
TextField textField1 = new TextField();
TextField textField2 = new TextField();
TextField textField3 = new TextField();
TextField textField4 = new TextField();
TextField textField5 = new TextField();
TextField textField6 = new TextField();
TextField textField7 = new TextField();
TextField textField8 = new TextField();
TextField textField9 = new TextField();
TextField textField10 = new TextField();
Button button1 = new Button();
Button button2 = new Button();
//Construct the frame
public NewClientFrame() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
catch(Exception e) {
e.printStackTrace();
//Component initialization
private void jbInit() throws Exception {
this.getContentPane().setLayout(null);
this.setSize(new Dimension(411, 488));
this.setTitle("NewClientFrame ");
this.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(WindowEvent e) {
this_windowClosing(e);
label1.setBounds(new Rectangle(21, 23, 110, 23));
label1.setAlignment(2);
label1.setText("Assign Number");
label2.setBounds(new Rectangle(23, 57, 108, 25));
label2.setAlignment(2);
label2.setText("Name");
label3.setBounds(new Rectangle(40, 91, 94, 24));
label3.setAlignment(2);
label3.setText("Address 1");
label4.setBounds(new Rectangle(21, 124, 112, 29));
label4.setAlignment(2);
label4.setText("Address 2");
label5.setBounds(new Rectangle(20, 159, 116, 29));
label5.setAlignment(2);
label5.setText("PoscCode");
label6.setBounds(new Rectangle(18, 197, 119, 26));
label6.setAlignment(2);
label6.setText("Telephone");
label7.setBounds(new Rectangle(25, 228, 112, 26));
label7.setAlignment(2);
label7.setText("Other Telephone");
label8.setBounds(new Rectangle(12, 261, 125, 24));
label8.setAlignment(2);
label8.setText("Email Address");
label9.setBounds(new Rectangle(6, 301, 138, 25));
label9.setAlignment(2);
label9.setText("Staff Assigned (Name)");
label10.setBounds(new Rectangle(22, 341, 124, 23));
label10.setAlignment(2);
label10.setText("Staff Assigned (No.)");
textField1.setBounds(new Rectangle(155, 19, 80, 26));
textField2.setBounds(new Rectangle(155, 58, 193, 24));
textField3.setBounds(new Rectangle(156, 90, 192, 25));
textField4.setBounds(new Rectangle(157, 126, 192, 23));
textField5.setBounds(new Rectangle(157, 159, 195, 25));
textField6.setBounds(new Rectangle(157, 194, 195, 26));
textField7.setBounds(new Rectangle(157, 230, 192, 24));
textField8.setBounds(new Rectangle(157, 263, 193, 25));
textField9.setBounds(new Rectangle(157, 303, 196, 24));
textField10.setBounds(new Rectangle(158, 337, 95, 24));
button1.setBounds(new Rectangle(23, 398, 144, 34));
button1.setLabel("Staff Available");
button2.setBounds(new Rectangle(211, 396, 148, 34));
button2.setLabel("Submit Record");
button2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button2_actionPerformed(e);
this.getContentPane().add(label1, null);
this.getContentPane().add(label2, null);
this.getContentPane().add(label3, null);
this.getContentPane().add(label4, null);
this.getContentPane().add(label5, null);
this.getContentPane().add(label6, null);
this.getContentPane().add(label7, null);
this.getContentPane().add(label8, null);
this.getContentPane().add(label9, null);
this.getContentPane().add(label10, null);
this.getContentPane().add(textField1, null);
this.getContentPane().add(textField2, null);
this.getContentPane().add(textField3, null);
this.getContentPane().add(textField4, null);
this.getContentPane().add(textField5, null);
this.getContentPane().add(textField6, null);
this.getContentPane().add(textField7, null);
this.getContentPane().add(textField8, null);
this.getContentPane().add(textField9, null);
this.getContentPane().add(textField10, null);
this.getContentPane().add(button1, null);
this.getContentPane().add(button2, null);
public void fileExit_actionPerformed(ActionEvent e) {
System.exit(0);
// exit(this);
// close();
//Overridden so we can exit on System Close
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if(e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
void button2_actionPerformed(ActionEvent e) {
// myFrame.close();
this.dispose();
void this_windowClosing(WindowEvent e) {
this.dispose();
I also have an about box, staff details, and valuation forms.
what I am trying to do is for the New client form to be able to read and write from and to a file, and display the info.
I am working in JBuilder3, a bit out of date I know, but it is the best I can do. Any Ideas how to do this. -
Quickest method for reading and writing files
Hi
I need help regarding file operations.(Reading and Writing). Currently I am using BufferedReader and BufferedWriter to read and write files. But the files (XML) are very huge files(from 30 -50 mb). This is slowing the application to a great extent. Is there any other approach to perform the above mentioned operations on XML files in a fast manner.
Thank You
Mansoor.Hi
Can u let me know how to use the java.nio pavkage for primitve data types(int,float..., boolean). I have tried it but found no success.
Thank You
Mansoor -
I have duplicated a project to work on another computer. The project opens fine but when I import new footage/audio files I get this message. "File importer detected an inconsistency in the file stucture of (file name). Reading and writing this file's metadata (XMP) has been disabled." Then I can't play my timeline and Premier Pro crashes. I have to force quit and restart my computer to continue working. What does this error really mean? How do you rectify?
Our workflow requires that we duplicate projects to make updates because we are frequently revising but need to keep original project unchanged and intact.I have a similar issue and message , but occurs when I import AVI clips from OnLocation CS4 to Premier Pro CS4.
-
IPhone4 how through the USB mobile phone file reading and writing?
iPhone4 how through the USB mobile phone file reading and writing?
No idea what you are asking.
Please explain
Maybe you are looking for
-
Titles in themes imovie 6.0.3
Is there a way to change the fonts of the titles within themes in the imovie version 6.0.3 ???
-
Cannot connect to I tunes store while trying to do updates or to purchase
Does anyone know how to fix this issue, I get an error message"cannot connect to iTunes store" when I try to do updates or to purchase anything from iBooks or iTunes does anyone know how to resolve this?
-
Billing against delivery order from bank
Dear All, If we are giving delivery against Delivery Order given by the bank, do we have to map this scenario in sap or how do map this. some suggestions Edited by: varada rajan on Jan 15, 2008 9:18 AM
-
IDoc transfer error - Message Type Conversion
Hi, While trying to transfer an IDocs from a 46C system, i get the following STATUS message in transaction BD87 Message type RPM_TIME could not be converted Message no. EA 694 Diagnosis Conversion entry between long and short names missing. System Re
-
Manage iPhoto on internal & external HD
Just bought a 15" rMBP (256GB HD capacity) and haven't opened yet. I've backed up my existing 2010 MBP iPhoto's libary to 1.5 TB external and plan to leave it on the external since just the iPhoto library alone is almost 200GB. I would like to use