How to append an array
HI, i need to know how i add data to an array. I can read the data from a textfile and print that at command line. But how do i put them in an array and print the array? The following is my code.
<code>
try{
BufferedReader in = new BufferedReader (new FileReader ("moparams"));
int count=0;
while(in.ready()) {
while(st.hasMoreTokens()){
double numbers[] = new double[20];// Numbers to be added here
String s = st.nextToken();
double d = Double.parseDouble(s);
//int j=Integer.parseInt(s);
System.out.println(d + " "); // replace "d" with "j"
count++;
System.out.println("Output No: " + count + " is "+d );
} // End of loop for while
System.out.println("The count is " + count);
in.close(); // added for while(in.ready())
} // End of try
catch (Exception e) {
System.err.println(e); // Print the exception to warn.
</code>
I Tried to add the follwoing code to append an array
<code>
for (int i=0;i<=count ; count++ )
//numbers.append(s);
numbers[i].add(d);
System.out.println("The count is " + count );
System.out.println("The array lements are"+array[i]);
</code>
I need to put the value "d" into an array. I donno how to add values into an array.
Thanks
Hey, i accidentally typed the int array. It is not in the code. I actually tried this that you have said, declaring the double array outside. But it doesnthelp. Check This
try{
int count=0;
double numbers[] = new double[20];
while(in.ready()) {
String line = in.readLine();
StringTokenizer st = new StringTokenizer(line);
while(st.hasMoreTokens()){
String s = st.nextToken();
double d = Double.parseDouble(s);
numbers[count]=d;
System.out.println("number["+count+"] ="+numbers[count]);
count++;
System.out.println("The output No: " + count + " is "+d );
System.out.println("Array is " + numbers[count]);
} // End of loop for while
System.out.println("The count is " + count);
in.close(); // added for while(in.ready())
catch (Exception e) {
System.err.println(e); // Print the exception to warn.
}The output is
number[0] =1.88972652066766
The output No: 1 is 1.88972652066766
Array is 0.0
1.0
number[1] =1.0
The output No: 2 is 1.0
Array is 0.0
0.331725538
number[2] =0.331725538
The output No: 3 is 0.331725538
Array is 0.0
2.0
number[3] =2.0
The output No: 4 is 2.0
Array is 0.0
1.227981
number[4] =1.227981
The output No: 5 is 1.227981
Array is 0.0
3.0
number[5] =3.0
The output No: 6 is 3.0
Array is 0.0
0.867287209
number[6] =0.867287209
The output No: 7 is 0.867287209
Array is 0.0
4.0
number[7] =4.0
The output No: 8 is 4.0
Array is 0.0
1.20594844
number[8] =1.20594844
The output No: 9 is 1.20594844
Array is 0.0
The count is 9
Similar Messages
-
How to append input array parameter to a conditon in where clause
CREATE OR REPLACE PROCEDURE file_upload(p_array_code IN DIAG_CODE,p_desc_code IN DIAG_CODE_DESC,p_code_result OUT DIAG_CODE_TABLE) IS
v_count NUMBER;
v_range1 VARCHAR2(8);
v_range2 VARCHAR2(8);
l_count pls_integer := 0;
l_diag_code_table1 DIAG_CODE_TABLE;
l_diag_code_table2 DIAG_CODE_TABLE;
l_loop_diag_code_table1 DIAG_CODE_TABLE;
l_loop_diag_code_table2 DIAG_CODE_TABLE;
BEGIN
l_loop_diag_code_table1 := diag_code_table();
l_loop_diag_code_table2 := diag_code_table();
FOR i IN 1..p_array_code.count
LOOP
SELECT diag_code_rec(d.icd9_pcs_text_href,
d.icd9_procedure_deci_code,
d.icd9_procedure_long_desc,
d.icd9_pcs_gem_flag_desc,
g.gem_icd9_icd10pcs_flag,
dc.icd10_procedure_code,
dc.icd10_procedure_long_desc)
BULK COLLECT INTO l_diag_code_table2
FROM icd9_procedure_codes d,
icd10_procedure_codes dc ,
gem_icd9_icd10pcs g
WHERE d.icd9_procedure_code=g.gem_icd9_pcs_code
AND g.gem_icd10_pcs_code=dc.icd10_procedure_code(+)
AND d.ICD9_PROCEDURE_code like p_array_code(i)||'%' ;
FOR j IN 1..l_diag_code_table1.count
LOOP
l_loop_diag_code_table1.extend;
l_loop_diag_code_table1 (l_loop_diag_code_table1.last):= l_diag_code_table1(j) ;
END LOOP;
END LOOP;
p_code_result := l_loop_diag_code_table1 ;
END;
DIAG_CODE_DESC is declared as type
create or replace type DIAG_CODE_DESC as table of varchar2(300);
p_desc_code contains array of keywords
I need to add one more condition to the above select query using the p_desc_code as
(regexp_like(S.ICD9_PROCEDURE_LONG_DESC, '(p_desc_code (1)') AND regexp_like(S.ICD9_PROCEDURE_LONG_DESC, '(p_desc_code (2))' and ... upto inpu array limit.
Could anyone help me through in writing the above the sql with the additional condition?
I would really appreciate the help.
Thanks,
in advanceBelow are the requirements:
A file will be uploaded from front end .
Data from the file will be sent as arrays from java code:
Two types of data
1. values from file
2. array of string values
data format from file
1.Sample data
1000
2000
3000
4000
array of strings upto 5 strings limiy
2.'abc','def',..upto 5
Both the input values are varchar.
create table ICD9_PROCEDURE_CODES(
ICD9_Procedure_Code Varchar2(6) Primary Key,
ICD9_Procedure_Deci_Code Varchar2(7),
ICD9_Procedure_Long_Desc Varchar2(300),
ICD9_Procedure_Short_Desc Varchar2(100),
ICD9_PCS_Gem_Flag_Desc Varchar2(500),
ICD9_Version Varchar2(10));
insert into icd9_procedure_code(ICD9_PROCEDURE_CODE , ICD9_PROCEDURE_DECI_CODE,
ICD9_PCS_TEXT_HREF, ICD9_PCS_GEM_FLAG_DESC)
values(0441 ,04.41 ,Decompression trigem ,Scenaroio0 ,Scenario0:text_href)
insert into icd9_procedure_code(ICD9_PROCEDURE_CODE , ICD9_PROCEDURE_DECI_CODE,
ICD9_PCS_TEXT_HREF, ICD9_PCS_GEM_FLAG_DESC)
0442, 04.42 ,Other carnial Cran ,Scenario1 ,Scenario1: text_href)
create table ICD10_PROCEDURE_CODES(
ICD10_PCS_Order_Num Varchar2(7),
ICD10_Procedure_Code Varchar2(8) Primary Key,
ICD10_Procedure_Decimal_Code Varchar2(9),
ICD10_PCS_Code_Header Number(1),
ICD10_Procedure_Short_Desc Varchar2(60),
ICD10_Procedure_Long_Desc Varchar2(300),
ICD10_PCS_Gem_Flag_Description Varchar2(500),
Version Varchar2(10),
insert into icd10_procedure_codes
( ICD10_PROCEDURE_CODE, ICD10_PROCEDURE_LONG_DESC, ICD10_PCS_TEXT_HREF, ICD10_PCS_GEM_FLAG_DESCRIPTION)
values
(00NK0ZZ,00N.K0ZZ, Release Nerve, Scenario0, Scenario0:text_href
00NK3ZZ, 00N.K3ZZ,Diabetes Neuropathy, Scenario11, Scenario11: text_href
00NK4ZZ, 00NK.4ZZ,Nerve disorder, Scenario12 ,Scenario12: text_href
create table GEM_ICD9_ICD10PCS(
GEM_ICD9_PCS_Code Varchar2(6),
GEM_ICD10_PCS_Code Varchar2(8),
GEM_ICD9_ICD10PCS_Flag Number(5),
GEM_Version Varchar2(10),
constaraint GEM_ICD9_ICD10PCS_PK PRIMARY KEY (GEM_ICD9_PCS_Code,GEM_ICD10_PCS_Code,GEM_ICD9_ICD10PCS_Flag))
insert into gem_icd9_icd10pcs (GEM_ICD9_PCS_Code,GEM_ICD10_PCS_Code,GEM_Version)
values
('0441','00NK0ZZ','10000');
('0441','00NK3ZZ','10000');
('0441','00NK4ZZ','10000');
Thanks for looking into this thread -
I use three read waveform nodes to read data from three channels of
oscilloscope. The data of each channel are 1D array, and I use build
array node to change them into 2D array. It can work well now.
When I want to continuously reading data, I put the read waveform nodes
and build array node into a while loop structure(a timer controls the
time when to stop). That means every time, the program calls read
waveform nodes and then changes them into 2D array. The problem is:after
each loop, the data stored in the 2D array are overwrited. So, at last,
I can only get the last loop data.
I want to append the data into the 2D array, but I do not know how to
implement? I have tried put the build array outside the while loop,
unfortunatel
y, it does not work.
Any advice would be appreciated.
Sent via Deja.com http://www.deja.com/
Before you buy.The shift register is a built in way to carry data forward from one
iteration of a loop to the next iteration.. Anything that you feed into the
right shift register appears a data at the beginning of the next loop. You
already have Build Array to combine three 1D array Elements into a single 2D
array. Use another Build Array function to combine the current 2D array
with the previous 2D array to create a combined array. To do this, you must
change the input mode of the Build Array function to Array (not Element).
This will concatenate the arrays and make the continuous data that you are
after.
The only other hidden step is that you must use Initialize Array to feed a
blank, 2D array into the left shift register to clear any leftover data.
Michael Munroe Mailto:[email protected]
A Better Complete Development Engineering Firm
San Mateo, CA 94403 http://www.abcdefirm.com
[email protected] wrote:
> Because I am very new to Labview and in fact, English is not my native
> language, I can not understand the sentence that "combine the current
> reading with the previous reading from the left shift register and save
> it back to the right shift register" means.
>
> Now, I want to descript my question in a simple way:
> In a while loop, I use a build array node to build three 1D arrays into
> one 2D array. For each time when while loop repeats, the value of these
> 1D arrays change, I want to append the new data to the previous ones.
> But in my program, the data in the build array are overrided after the
> while loop repeating.
> So, How to append the data instead of overriding them in the while loop
> structure?
>
> Thanks a lot!
>
> zhljh
>
> In article <[email protected]>,
> Michael Munroe wrote:
> > You need to combine the build array function with the shift register.
> Pop
> > up on the edge of the loop and Add Shift Register. You can combine the
> > current reading with the previous reading from the left shift register
> and
> > save it back to the right shift register.
> > --
> > Michael Munroe Mailto:[email protected]
> > A Better Complete Development Engineering Firm
> > San Mateo, CA 94403 http://www.abcdefirm.com
> >
> > [email protected] wrote:
> >
> > > I use three read waveform nodes to read data from three channels of
> > > oscilloscope. The data of each channel are 1D array, and I use build
> > > array node to change them into 2D array. It can work well now.
> > > When I want to continuously reading data, I put the read waveform
> nodes
> > > and build array node into a while loop structure(a timer controls
> the
> > > time when to stop). That means every time, the program calls read
> > > waveform nodes and then changes them into 2D array. The problem
> is:after
> > > each loop, the data stored in the 2D array are overwrited. So, at
> last,
> > > I can only get the last loop data.
> > > I want to append the data into the 2D array, but I do not know how
> to
> > > implement? I have tried put the build array outside the while loop,
> > > unfortunately, it does not work.
> > > Any advice would be appreciated.
> > >
> > > Sent via Deja.com http://www.deja.com/
> > > Before you buy.
> >
> >
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Michael Munroe, ABCDEF
Certified LabVIEW Developer, MCP
Find and fix bad VI Properties with Property Inspector -
i have a true false case inside a loop and each time
it pases through a false case . i pull out one value from the array(external). i would like to know if some one can help me in telling me how to append an element to an exisiting array or to create a array inside the false case structure.
THanks
Attachments:
append.vi 42 KBhello, well, I dun really understand what you wanna do. Here's my guess. Hope it helps
Cheers
ian.f k
SG/MY
Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010
依恩与LabVIEW
LVVILIB.blogspot.com
Attachments:
buildarray.vi 27 KB -
How to add byte[] array based Image to the SQL Server without using parameter
how to add byte[] array based Image to the SQL Server without using parameter.I have a column in table with the type image in sql and i want to add image array to the sql image column like below:
I want to add image (RESIM) to the procedur like shown above but sql accepts byte[] RESIMI like System.Drowing. I whant that sql accepts byte [] array like sql image type
not using cmd.ParametersAdd() method
here is Isle() method contentSQL Server binary constants use a hexadecimal format:
https://msdn.microsoft.com/en-us/library/ms179899.aspx
You'll have to build that string from a byte array yourself:
byte[] bytes = ...
StringBuilder builder = new StringBuilder("0x", 2 + bytes.Length * 2);
foreach (var b in bytes)
builder.Append(b.ToString("X2"));
string binhex = builder.ToString();
That said, what you're trying to do - not using parameters - is the wrong thing to do. Not only it is insecure due to the risk of SQL injection but in the case of binary data is also inefficient since these hex strings are larger than the original byte[]
data. -
How to append records in a file, through file adapter.
Hi All,
How to append records in a file, through file adapter.
I have to read data from database and need to append all records in a file.
Thanks in Advance.Hi,
I think you have a while loop to hit the DB in your Process (As you said you have to fetch data from DB 10 times if 1000 rec are there)
First sopy your DB O/P to one var
and from second time append to previous data.(Otherwise you can directly use append from starting instead of copy and append)
When loop completes you can transform to File adapter Var.
Otherwise you can configure yourFileadapter such that it will aapend current records to previous records.
You can use 'Append= true' in your file adapter wsdl.
It will append previous records to current records in the same file.
Regards
PavanKumar.M -
How to append calling and called number with translation rules?
Hello,
I have one question about digit manipulations.
How to append calling number and called number with IOS commands?
For example, when 123 dials 45678, translations have to be performed and the new called number to be 12345678.
Thank you,
I will vote this conversation.It is not possible with translation rules.
However, you can do that with a TCL/IVR script. -
How to map an array to fixed fields using Biztalk mapper
I need to remap an array of objects like this:
<Root>
<ListOfObjs>
<Obj>
<Attr1>0000</Attr1>
<Attr2>Hello!</Attr2>
</Obj>
<Obj>
<Attr1>1111</Attr1>
<Attr2>Hello1!</Attr2>
</Obj>
</ListOfObjs>
</Root>
in an output like this:
<Root>
<Obj1_Attr1>0000</Obj1_Attr1>
<Obj1_Attr2>Hello!</Obj1_Attr2>
<Obj2_Attr1>1111</Obj2_Attr1>
<Obj2_Attr2>Hello1!</Obj2_Attr2>
</Root>
So in my XSD schema I have something like this:
Schema Input
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element name="ListOfObjs">
<xs:complexType>
<xs:sequence>
<xs:element name="Obj">
<xs:complexType>
<xs:sequence>
<xs:element name="Attr1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Attr2">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
Schema output
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element name="Obj1_Attr1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Obj1_Attr2">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Obj2_Attr1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Obj2_Attr2">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
In addiction I have to evaluate every single value because when I found some conditions (like if value=0000 output should be NULL).
What would be the best way to do it? I'm thinking to develop a custom functoid but I'm not sure it would be the best way, probably it could be done even using XSLT inline transforms, can you point me in the best direction?
Thank youHi,
You cannot directly map an array output to any single field in BizTalk mapper.
Couple of options :
1) create
the Xslt or inline C# code
Refer:
http://seroter.wordpress.com/2008/10/07/splitting-delimited-values-in-biztalk-maps/
2) Shankycheil has
provided a solution to similar requirement in the below link, u can also refer that.
https://social.msdn.microsoft.com/Forums/en-US/55ec472d-4f34-4057-b1c6-0e50740f0f6e/how-to-itterate-string-array-values-in-biztalk-mapper?forum=biztalkgeneral
Rachit
Thank you, I already seen both posts, but I'm not sure they are what I need or I can't understand well how to use them.
Speaking about the first solution, as I told before, in the example I should have an array already formed and delimited by a char (something like "obj1attr1-obj1attr2-ob2attr1-obj2attr2". In this situation probably this example could be a good
point to start from, but how to transform my complex input object in a similar formatted string?
About the second I don't understand well what is the working solution that they have adopted. Is the 4 steps solution suggested by Shankycheil? If yes, how can I loop between all array elements and extract all their values? -
How to build a array with high sampling rates 1K
Hi All:
Now I am trying to develop a project with CRio.
But I am not sure how to build a array with high sampling rates signal, like >1K. (Sigle-point data)
Before, I would like to use "Build Arrary" and "Shift Register" to build a arrary, but I found it is not working for high sampling rates.
Is there anyother good way to build a data arrary for high sampling rates??
Thanks
Attachments:
Building_Array_high_rates.JPG 120 KBCan't give a sample of the FPGA right now but here is a sample bit of RT code I recently used. I am acquiring data at 51,200 samples every second. I put the data in a FIFO on the FPGA side, then I read from that FIFO on the RT side and insert the data into a pre-initialized array using "Replace Array subset" NOT "Insert into array". I keep a count of the data I have read/inserted, and once I am at 51,200 samples, I know I have 1 full second of data. At this point, I add it to a queue which sends it to another loop to be processed. Also, I don't use the new index terminal in my subVI because I know I am always adding 6400 elements so I can just multiply my counter by 6400, but if you use the method described further down below , you will want to use the "new index" to return a value because you may not always read the same number of elements using that method.
The reason I use a timeout of 0 and a wait until next ms multiple is because if you use a timeout wired to the FIFO read node, it spins a loop in the background that polls for data, which rails your processor. Depending on what type of acquisition you are doing, you can also use the method of reading 0 elements, then using the "elements remaining" variable, to wire up another node as is shown below. This was not an option for me because of my programs architecture and needing chunks of 1 second data. Had I used this method it would have overcomplicated things if I read more elements then I had available in my 51,200 buffer.
Let me knwo if you have more qeustions
CLA, LabVIEW Versions 2010-2013
Attachments:
RT.PNG 36 KB
FIFO read.PNG 4 KB -
How to append a picture in a mail?
Hello!
How to append a picture which like gif file in a e-mail?
Like OutlookExpress append picture,but not just append attach file..
I want it look like a part of htm.
Not look like a attach file.
Please help~
Excuse me,I am not good in English.
Best Regards
Alexjust coding like what u have done with append attach file in the bodypart.
then, set the bodypart header "Content-Disposition"
eg.
mimebodypart.setHeader("Content-Disposition", "inline; filename=xxx.jpg"); -
How to set an array element in an object type of array??
Hi,
I have set attribute as follow:
Color[] colors;
Color[] colors = new Color[20];
colors[0] = "Red";
colors[1] = "blue";I can't compile this code. It said:
"Incompatible type -found java.lang.String but expected Colors
Could you tell me how to set an array elements when the array type is an object?in your case, the array shouldn't be Color[] but String[] since you re intending to put strings into it
by the way, you could also use a hashmap to map a string to a color:
HashMap<String, Color> hm = new HashMap<String, Color>();
hm.put("Red", Color.RED);
hm.put("Blue", Color.BLUE);
etc. -
How to append html formatted text to JPaneText?
Hi,
I'm trying to append html to JPaneText and I can't do it. My code is below:
import java.awt.*;
import javax.swing.*;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.*;
import javax.swing.text.*;
public
class GUI
extends JFrame {
JTextPane wynikTxtAre = new JTextPane();
JScrollPane suwak = new JScrollPane(wynikTxtAre);
JPanel panelSrodek = new JPanel();
HTMLDocument doc;
HTMLEditorKit kit = new HTMLEditorKit();
public GUI()
super.setSize(640, 480);
super.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
wynikTxtAre.setEditable(false);
wynikTxtAre.setDocument(kit.createDefaultDocument());
doc = (HTMLDocument)wynikTxtAre.getDocument();
suwak.setPreferredSize(new Dimension(600, 400));
panelSrodek.add(suwak);
super.getContentPane().setLayout(new BorderLayout());
super.getContentPane().add("Center", panelSrodek);
super.setVisible(true);
public static void main (String [] args) {
GUI g = new GUI();
try {
Style style = g.doc.addStyle("StyleName", null);
StyleConstants.setItalic(style, true);
StyleConstants.setFontSize(style, 30);
StyleConstants.setBackground(style, Color.blue);
StyleConstants.setForeground(style, Color.white);
// Append to document
g.kit.insertHTML(g.doc, g.doc.getLength(), "tekxt", 1, 1, HTML.Tag.B);
//g.doc.insertString(g.doc.getLength(), "<b>Some Text</b>", style);
} catch (Exception e) {
System.out.println(e.getMessage());
If i use insertHTML method then there is no text on the text area.
If i use insertString method then text appear but it doesn't resolve html tags.
Please help.I did something like this:
public
class GUI
extends JFrame {
//previous code - no changes
public static void main (String [] args) {
GUI g = new GUI();
StringBuffer buf = new StringBuffer();
try {
buf.append("<b>bb</b>");
buf.append("<b>ccc</b>");
// First append to document
g.pane.setText(buf.toString());
//Second append
buf.append("<b>ddddd</b>");
g.pane.setText(buf.toString());
} catch (Exception e) {
System.out.println(e.getMessage());
I know that this method is not smart and doesn't look good, but it works.
If you know how to append html using HTMLEditorKit and HTMLDocument please write some example. -
How to get byte array from jpg in resource for Image XObject?
Hi,
Does anyone know how to get an array of bytes from a jpg from resource without an external library except MFC?
The array of bytes is needed to create an Image XObject so it can be included in an appearance for an annotation.Sounds like a standard Windows programming question, not specific to the SDK.
-
How to Append two word documents into single using java
How to Append two word documents into single using java
we tried this but it's not append the one word document to other
source code:public class AppendTwoWordFiles {
public static void main(String []arg)throws IOException
FileInputStream fi=null;
FileOutputStream fo=null;
try {
System.out.println("Enter the source file name u want to append");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
File f1=new File(br.readLine().toString());
System.out.println("Enter the Destination file name ");
File f2=new File(br.readLine().toString());
fi = new FileInputStream(f1);
fo = new FileOutputStream(f2,true);
byte b[]=new byte[2];
while((fi.read(b))!=-1);
fo.write(b);
System.out.println("Successfully append the file");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
finally{
fi.close();
fo.close();
plz reply me quickly ,,,what can i followUse this code ..
and give the path of the both file like this.....
source file ---- C:/workspace/Practice/src/com/moksha/ws/test/practice.text
destination file ---- C:/workspace/City/src/com/moksha/ws/test/practice1.text
import java.io.*;
public class AppendTwoWordFiles {
public static void main(String[] arg) throws IOException {
FileInputStream fi = null;
FileOutputStream fo = null;
try {
System.out.println("Enter the source file name u want to append");
BufferedReader br = new BufferedReader(new InputStreamReader(
System.in));
File f1 = new File(br.readLine().toString());
System.out.println("Enter the Destination file name ");
File f2 = new File(br.readLine().toString());
fi = new FileInputStream(f1);
fo = new FileOutputStream(f2, true);
byte b[] = new byte[2];
int len = 0;
while ((len = fi.read(b)) > 0) {
fo.write(b, 0, len);
System.out.println("Successfully append the file");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
fi.close();
fo.close();
} -
How to append a file in a trigger?
I'm writing from a table to a file, and have created a trigger that works great...however, I need to append the file so it doesn't overwrite the file every time the trigger fires.
Here's the code...but I can't figure out how to append the file instead of just write to the file:
CREATE OR REPLACE TRIGGER checkout_trg
AFTER UPDATE OF movie_qty ON mm_movie
FOR EACH ROW
DECLARE
fh UTL_FILE.FILE_TYPE;
BEGIN
IF :NEW.movie_qty=0 THEN
fh:=UTL_FILE.FOPEN('ORA_FILES','chekcout.txt','w');
UTL_FILE.PUT_LINE(fh, 'Date: '||sysdate||', Movie ID: '||:NEW.movie_id||', Quantity: '||:NEW.movie_qty);
UTL_FILE.FCLOSE(fh);
END IF;
END;
/> It's for an assignment...I think thye're just trying to show us what's possible.
Just as it is possible to show a learner driver to jump a red light, drive on the wrong side of the road, or do doughnuts in an intersection...
But none of this will make that learner driver a good driver. Never mind able to correctly handle high performance cars on the professional circuit.
Sorry mate - what they are showing/teaching you is pure bs. A trigger is not the "same thing" as a callback event in client programming.
And feel free to give them this URL and tell them that I think they are full of it. Let's see how they defend their non-real world, totally irrelevant and wrong assignments in this very forum.
Maybe you are looking for
-
Bank Charges - Outgoing Payment
Hi All, Customer want to post an entry in outgoing payment, which is not a cheque but he wants to take Demand Draft. Hence he has to add bank charges in the outgoing payment along with normal outstanding amount. Vendor outstanding is Rs. 10,000 Bank
-
How to change release date in UCM
Hi How to change the date(release date) of the released content? Thanks Deepak
-
IPhone 5 not working properly with USB interface in Honda Accord.
The iPhone 5 seems not to work properly with the USB interface in my 2012 Honda Accord. It says I have 500 songs when I only have 430, it skips over songs and freezes during play.
-
Hi I have a BPMN model with an initiating step that has a form behind it and each time I try to test it I get the following error: I don't have 'completedDetails' in the dataobjects or schema's behind the activity or human task. Please assist. Thanks
-
My bb doesn't connect to browser or app world pls help.
i have a bb 9300 and my browser does not load, also app world doesn't work, it tells me i have to upgrade but since i cannoct connect to the browser i cant do it. i cannot connect my emails either although apps such as fb work.. whats the problem and