Write text file - overwriting content
Created: 2010-10-28 16:45:04
The beanshell creates an empty temporary file. The filepath to the temporary file is then passed to the Write_text_file A service which writes the string 'hello' into the file. After service A has run, service B writes 'goodbye' into the file. The file is then read by the Read_Text_File service and its content, 'goodbye', output by the workflow.
Preview
Run
Run this Workflow in the Taverna Workbench...
Workflow Components
Authors (1)
Titles (3)
Write text file - overwriting content |
Write text file - overwriting content |
Write text file - overwriting content |
Descriptions (1)
The beanshell creates an empty temporary file. The filepath to the temporary file is then passed to the Write_text_file A service which writes the string 'hello' into the file. After service A has run, service B writes 'goodbye' into the file. The file is then read by the Read_Text_File service and its content, 'goodbye', output by the workflow. |
Dependencies (0)
Processors (6)
Name |
Type |
Description |
Create_temporary_file |
beanshell |
ScriptFile temp = File.createTempFile("taverna", "txt");
temp.deleteOnExit();
out = temp.getCanonicalPath(); |
Write_Text_File_A |
localworker |
ScriptBufferedWriter out = new BufferedWriter(new FileWriter(outputFile));
out.write(filecontents);
out.close();
outputFile = filecontents;
|
Write_Text_File_B |
localworker |
ScriptBufferedWriter out = new BufferedWriter(new FileWriter(outputFile));
out.write(filecontents);
out.close();
outputFile = filecontents;
|
Read_Text_File |
localworker |
ScriptBufferedReader getReader (String fileUrl) throws IOException {
InputStreamReader reader;
try {
reader = new FileReader(fileUrl);
}
catch (FileNotFoundException e) {
// try a real URL instead
URL url = new URL(fileUrl);
reader = new InputStreamReader (url.openStream());
}
return new BufferedReader(reader);
}
StringBuffer sb = new StringBuffer(4000);
BufferedReader in = getReader(fileurl);
String str;
String lineEnding = System.getProperty("line.separator");
while ((str = in.readLine()) != null) {
sb.append(str);
sb.append(lineEnding);
}
in.close();
filecontents = sb.toString();
|
hello |
stringconstant |
Valuehello |
goodbye |
stringconstant |
Valuegoodbye |
Beanshells (1)
Name |
Description |
Inputs |
Outputs |
Create_temporary_file |
|
|
out
|
Outputs (1)
Name |
Description |
contents_of_written_file |
|
Datalinks (6)
Source |
Sink |
Create_temporary_file:out |
Write_Text_File_A:outputFile |
hello:value |
Write_Text_File_A:filecontents |
goodbye:value |
Write_Text_File_B:filecontents |
Create_temporary_file:out |
Write_Text_File_B:outputFile |
Create_temporary_file:out |
Read_Text_File:fileurl |
Read_Text_File:filecontents |
contents_of_written_file |
Coordinations (2)
Controller |
Target |
Write_Text_File_A |
Write_Text_File_B |
Write_Text_File_B |
Read_Text_File |
Uploader
License
All versions of this Workflow are
licensed under:
Version 1
(of 1)
Credits (0)
(People/Groups)
None
Attributions (0)
(Workflows/Files)
None
Shared with Groups (1)
Featured In Packs (0)
None
Log in to add to one of your Packs
Attributed By (0)
(Workflows/Files)
None
Favourited By (0)
No one
Statistics
Other workflows that use similar services
(0)
There are no workflows in myExperiment that use similar services to this Workflow.
Comments (0)
No comments yet
Log in to make a comment