Output into a text file
Hi all, i am trying to parse an xml doc from a url and the display the results in an text file, howver when i run the below code the Headers are coming up the the returned results are being displayed int the cmd prompt window, anyone have any ideas on how to display the results in a text file?
import org.apache.xerces.parsers.DOMParser;
import org.xml.sax.SAXException;
import java.io.IOException;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.w3c.dom.NamedNodeMap;
import java.util.Properties;
import java.io.*;
public class IsbnSearch{
public static void main(String args[]) throws IOException, SAXException{
//Check out: http://www.rgagnon.com/javadetails/java-0085.html
Properties systemSettings = System.getProperties();
systemSettings.put("http.proxyHost", "staff-proxy.ul.ie");
systemSettings.put("http.proxyPort", "8080");
System.setProperties(systemSettings);
FileOutputStream out; // declare a file output object
PrintStream p ; // declare a print stream object
String isbn;
String size;
BufferedReader reader;
reader = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Please enter Isbn Number\n");
try {
out = new FileOutputStream("myfile.xls");
p = new PrintStream( out );
isbn = reader.readLine();
System.out.print("Please Choose the Level of Detail you require:\n");
System.out.print("Small, Medium or Large\n");
size = reader.readLine();
DOMParser parser = new DOMParser();
parser.parse("http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&Version=2005-03-23&Operation=ItemLookup&ContentType=text%2Fxml&SubscriptionId=0525E2PQ81DD7ZTWTK82&ItemId="+isbn+"&IdType=ASIN&ResponseGroup="+size+"");
Document dom = parser.getDocument();
p.println("\nTitle:");
getAttribute(dom, "Title");
p.println("\nAuthor:");
getAttribute(dom, "Author");
p.println("\nImage:");
getAttribute(dom, "SmallImage");
p.println("\nISBN:");
getAttribute(dom, "ISBN");
p.println("\nBinding:");
getAttribute(dom, "Binding");
p.println("\nReview:");
getAttribute(dom, "Content");
p.println("\nDetail Website Please Visit =:");
getAttribute(dom, "DetailPageURL");
p.println("\nTime to process Request:");
getAttribute(dom, "RequestProcessingTime");
catch (IOException ioe) {
System.out.println("I/0 Exception Occurresd");
private static void getAttribute(Document dom, String tagName)throws IOException {
NodeList ItemAttributes = dom.getElementsByTagName(tagName);
for(int i=0;i<ItemAttributes.getLength();i++){
Node aNode = ItemAttributes.item(i);
System.out.println(aNode.getFirstChild().getNodeValue());
NamedNodeMap attributes = aNode.getAttributes();
for (int a=0;a<attributes.getLength();a++){
Node theAttribute = attributes.item(a);
System.out.println(theAttribute.getNodeName() + "="+ theAttribute.getNodeValue());
}
I suppose you mean that the output of this line of codeSystem.out.println(theAttribute.getNodeName() + "="+ theAttribute.getNodeValue());is coming out on the console? Yup. That's what System.out is for. Let me point you at the Java I/O tutorial:
http://java.sun.com/docs/books/tutorial/essential/io/index.html
It explains how to write to a file.
Similar Messages
-
Hello Experts,
There is a situation where i need ur help.My query is :
Can I export the output of more than one queries into a * Single Text File * ?
Also can it be possible to automate these Queries Output to export into the Text File ??
I also want this Text File Output to mail the end users by using the Process Chain. So is this possible to create a process chain for sending this Text File to the Users via mail ??
Thanks In Advance
NehaHello Neha,
Though i have been working with APDs since some time. But havent actually been involved in designing one. But you could find many documents for the APD on web. And as far as i know, you will need a program to save file from APD.
I have a document which explains how you can use APD in process chain. can forward you the same if you want.
I am sorry as i wasnt of much help for you, as i havent worked on similar requirement before, but this thing just striked in my mind.
Regards,
Anuj -
How to output a query results into a text file
How to output a query results into a text file instead of outputing it to the screen..
is there a way for us to write a SQL query which specifies to output the query results to a text file.
Pls let me know how to do it
Thanking u in advance
regards
MuralyMuraly,
If you are using SQL*Plus 8.1.6 or later, you can also spool output to a file in HTML format, eg
SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON
SPOOL c:\temp\report.html
SELECT DEPARTMENT_NAME, CITY
FROM EMP_DETAILS_VIEW
WHERE SALARY>12000;
SPOOL OFF
SET MARKUP HTML ENTMAP OFF
In iSQL*Plus 9.0.1 (the browser-based interface to SQL*Plus) onwards, you can also send the HTML output to a new web browser window, or an html file -- much easier than the command line method.
Alison -
Grabbing numbers from an array of type double and outputting them into a text file
In a program im creating i need to save some coordinates of a micropositioner i have into a text file,
I have the coordinates saved into an array that has 6 digits of precision (6 places after the decimal point).
I use the number to string conversion and wire that into the write to text file function in labview. When i open the file
the numbers that are only displayed are the ones to the left of the decimal point. I know the number to decimal string function
rounds the values so if i were to input 3.111111 it would only output the string "3" instead of "3.111111" .
So to get all the digits onto the file without rounding i multiplied the number by 10^6 but the decimal point will be lost at that point.
Is there anyway i can convert numbers into strings without labview rounding to the nearest whole number also without having to multiply by 10^6 and without having to expect the user to know that the coordinates saved in a file are multiplied by an order of magnitude of a million ?ed oh i guess i just missed that function on the pallete after i saw that the function went from number to hex, octal, etc. i assumed that the rest on that row would be some sort of conversion to a different base number, haha thanks.
-
OMB Plus : how to get all the generated messages into a text file ?
Hello,
I wrote an OMB TCL script and I would like to know how to get all the messages generated during the exécution into a text file.
I tried this, but it works only for a puts command :
set DesProjet ACT_1
set filename [ open "c:\\temp\\INFDE_010_IMPORT_REPOSITORY_$DesProjet.log" w]
puts "test"
Thank you for your helpHello Alain, you should try the OMBLOG variable. If you set it inside OMBPlus:
set OMBLOG c:/temp/mylog.txtthen all the OWB specific commands are logged with their output. By OWB specific I mean all those that start with OMB.
This is more than what you see in the interface, because:
- messages inside procedures are logged; you wouldn't see them on std.output when you call a proc
- variables are resolved, so if you issue the command
set my_var VERY_IMPORTANT_TABLE
OMBDROP TABLE '$v_myvar'the log will show:
OMBDROP TABLE 'VERY_IMPORTANT_TABLE'
Table dropped
and you know something is wrong... so OMBLOG is very useful to intercept all manipulations on you repository.
If what you want instead is a dump of the screen output when you execute a script, I suggest you redirect standard output from the operating system command line. Unfortunately OMBPlus doesn't support all advanced redirection and tracing features of the TCL language.
Hope this helps, Antonio -
Scheduling multiple tab BO XI3 report needs to save into multiple text file
Hi,
I have BO XI 3 Desktop Intelligence reports, those reports contains multiple tabs. Once after scheduling these reports the output needs to save as different text files (each tab as separate text file). Generally when select output as text file we will get the text file with the data of current tab, but in this scenario I want all the tabs data into different text files. I guess we can do this with macro. But I am not good in macro development, hope somebody can help me.
Could you please help out for the same!
Thanks,
RamaThanks Dan.. I made chenges in code as per your suggestion.. its working fine in DeskI -> local PC
But this is not working in InfoView level... when i scheduled the same report its not saving into multiple text files... can you please have look...
macro code as follows:-
Public Sub SaveAsText()
Dim StrTxtPath As String
Dim BusDoc As busobj.Document
Set BusDoc = ThisDocument
Dim BusRep As Report
Dim I As Integer
On Error GoTo ErrHandler
'StrTxtPath = "
xxxx.xxx.xxx.com\common\Reporting\"
StrTxtPath = "D:\Business Objects\Test_Macro\"
For I = 1 To BusDoc.Reports.Count
Set BusRep = BusDoc.Reports.Item(I)
BusRep.ExportAsText (StrTxtPath & BusRep.Name)
Next I
ErrHandler:
Exit Sub
End Sub
When i run this macro through DeskI.. its saving the report as multiple .txt files with respective number of tabs... but the same thing is not working when i tried in scheduling...
Can you please suggest me what are the changes needs to be done...
Thanks in Advance
Thanks,
Rama -
How to resend the RMAN output to a text file
Hi ,
I am using RMAN for backup purpose.
How should we send the output of RMAN to a text file.
For Example If we issue the following command then how should we send the results of that command into a text file:
RMAN> report obsolete device
type 'sbt_tape';
result:
RMAN-03022: compiling command: report
RMAN-06147: no obsolete backups found
Any ideas will be great for me.
Thanks
KumarExample:
[oracle@ozawa oracle]$ sqlplus /nolog
SQL*Plus: Release 9.2.0.1.0 - Production on Thu Mar 4 09:38:40 2004
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL> spool my_output.txt
SQL>
SQL> host rman target /
Recovery Manager: Release 9.2.0.1.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
connected to target database: LQACNS1 (DBID=1237456636)
RMAN>
RMAN>
RMAN> quit
Recovery Manager complete.
SQL>
SQL> spool off
SQL>
SQL> quit
Joel Pérez -
Not able to save report output in a text file and RTF file
I am using Oracle Developer6.0 . I am facing problem with reports. I am invoking reports from form using run_product.
1. I could not able to save the report in text file . Whenever i try to save the report output in a text file.It gives dump and application get closed.
2. In RTF format , it execute the query which i have given at the design time while creating a report . But while running i am passing query either through lexical parameter or passing value of where criteria user parameters. It display the output for the specified value. But when i save this report output in rtf file . It execute design time query and save that in a rtf file.
If any body is having any idea about it . Please let me ASAP . It is very urgent for me.
Thanks in advanceTry the following:
Do not generate the report to .rep file, but rename/copy the .rdf file to .rep file and execute it. -
Download Internal Table into a Text File in BSP?
I have an internal table which i need to download into my local pc. I know i can not use FM gui_download. Could some one please post code on how to download the internal table into a text file in BSP. Also i am not sure if i can use save dialog FM. Also need suggestion on which FM to use for save dialog which tells where to save the file.
Any help will be appreciated.
Thanks
NahmanThis might be a good starting point.
<a href="/people/thomas.jung3/blog/2004/09/02/creating-a-bsp-extension-for-downloading-a-table">/people/thomas.jung3/blog/2004/09/02/creating-a-bsp-extension-for-downloading-a-table</a> -
Write arrays into a text file in different columns at different times
Hi,
I have a problem write data into a text file. I want to write 4 1D arrays into a text file. The problem is that I need to write it at different time and in different column (in other word, not only append the arrays).
Do you have an idea to solve my problem?
Thank youA file is long a linear string of data (text). In order ro insert columns, you need to rewrite the entire file, because colums are interlaced over the entire lenght of the file.
So:
read file into 2D array
insert columns using array operations
write resulting 2D array to file again.
(Only if your colums are guaranteed to be fixed width AND you know the final number of colums, you could write the missing columns as spaces and then overwrite later. Still, it will be painful and inefficient, because column data are not adjacent in the file.)
LabVIEW Champion . Do more with less code and in less time . -
ORA-06521: PL/SQL: Error mapping function while writting into a text file
Hi,
I'm getting an errror ORA-06521: PL/SQL: Error mapping function while trying to write data into a text file.
I'm using the following code:
--To create a new directory
create or replace directory temp as 'C:/temp';
declare
l_str varchar2(1000);
output_file utl_file.file_type;
cursor test_write_cur is
select EMPNO,ENAME,JOB,SAL,HIREDATE
from EMP
where DEPTNO=30;
begin
output_file := utl_file.fopen('TEMP','TESTFILE.txt','w');
for test_write_rec IN test_write_cur
loop
l_str := test_write_rec.EMPNO||'^'||test_write_rec.ENAME||'^'||test_write_rec.JOB||'^'||
test_write_rec.HIREDATE||'^'||test_write_rec.SAL||chr(10);
utl_file.put_line(output_file,l_str);
end loop;
utl_file.fclose(output_file);
end;Please suggest me if i'm wrong.
Thanks & Regards,
Sanket MishraDear Sanket,
I think you are need use TO_CHAR() function
to_char(test_write_rec.EMPNO) ,
to_char(test_write_rec.HIREDATE,'DD.MM.YYYY')
to_char(test_write_rec.SAL) -
How to convert a HTML files into a text file using Java
Hi guys...!
I was wondering if there is a way to convert a HTML file into a text file using java programing language. Likewise I would also like to know if there is a way to convert any type of file (excel, power point, and word) into text using java.
By the way, I really appreciated the help that you guys gave me on my previous topic on how to extract tests from a pdf file.
Thank you....HTML files are already text files. What do you mean you want to convert them?
I think if you search the web, you can find things for converting those MS Office files to text (or extracting text from them, as I assume you mean). -
How to extract the Html content of a UI Map into a text file or html file?
Hi,
Is there any possibility in OUAF or Java or from the Database, to retrieve the Html Content of a given a UI Map ?
If UI Map name is the input, then it should fetch the entire html portion of it into a text file. How to acheive this?
This needs to be done programatically either by writing some Java code or some SQL at the DB level?
Edited by: OATS Explorer on Dec 29, 2012 9:10 AMF1_MAP.HTML_DEFN would give the html contents and F1_SCHEMA.SCHEMA_DEFN would give you the UI Map's Schema.
SELECT map.map_cd
, map.html_defn
, sch.schema_defn
FROM f1_map map
, f1_schema sch
WHERE map.map_cd = sch.schema_name
AND sch.schema_type_flg = 'F1MP' -
Write Query Results into a text file
Hello All,
In SAP B1 Query Generator I'm trying to write the results of a query into a text file (.txt). I've tryed with queryout but it doesn't work.
What I want is something like this:
SELECT * FROM TABLE queryout "C:/textfile.txt"
Any sugestions?
Thanks in advance,
Miguel BarbosaHello All,
Since yesterday and due to your help, I've found how to solve my problem.
This post is only to share with you and with the others users of Expert Forums how to Write the results of an SQL Query in SAP Business One to a Text File without making it by exportation.
Requested Text File by customer:
Document type in R/3 If Invoice -- 'Z100' - Position 1 to 4 - 4 characters
Supplier Code -- dbo.Table.CardCode -- Position 5 to 15 - 10 characters
Item Code -- dbo.Table.ItemCode -- Position 11 to 25 - 14 characters
Client Code -- dbo.Table.CardCode -- Position 26 to 36 - 10 characters
Client Name -- dbo.Table.CardName -- Posiiton 37 to 100 - 63 characters
Fixed Blank Field -- ' ' -- Position 101 to 120 - 19 blank spaces
Quantity -- dbo.Table.Quantity -- Position 121 to 140 -- 19 characters
Unit Price -- dbo.Table.PriceBefDi -- Position 141 to 160 -- 19 characters
If Invoice Fixed identifier -- 'Z01' -- Position 161 to 163 -- 3 characters
Fixed Blank Field -- ' ' -- Position 164 to 220 -- 56 characters
Document Date -- dbo.Table.DocDate -- Position 221 to 229 - 8 characters
Delivery Date -- dbo.Table.ActDelDate -- Position 230 to 238 - 8 characters
Sales Order Number - dbo.Table.DocNum -- Position 239 to 260 - 21 characters
Delivery Number - dbo.Table.DocNum -- Position 261 to 282 - 21 characters
Follows the code:
EXEC master..xp_cmdshell'bcp
SELECT DISTINCT
''Z100''
+ ''ZP00002091''
+ IsNull(Convert(nVarChar(44), Cast(T0.DocNum As Numeric(38, 0))), '''')
+ ''PTAP''
+ '' ''
+ ((LTRIM(RTRIM(T1.U_NumConc)))) + SPACE(10-LEN(LTRIM(RTRIM(T1.U_NumConc)))) + ((LTRIM(RTRIM(T3.BaseRef)))) + SPACE(10-LEN(LTRIM(RTRIM(T3.BaseRef))))
+ '' ''
+ ''Z02''
+ CONVERT(varchar(10), T1.ActDelDate, 112)
+ CONVERT(varchar(10), T0.DocDate, 112)
+ '' ''
+ IsNull(Convert(nVarChar(44), Cast(T1.BaseRef As Numeric(38, 0))), '''')
+ ((LTRIM(RTRIM(T1.ItemCode)))) + SPACE(18-LEN(LTRIM(RTRIM(T1.ItemCode))))
+ ''0'' + REPLACE(SPACE(12-LEN(CONVERT(varchar(12), CAST(T1.Quantity AS NUMERIC (38,3))))),'' '',''0'') + REPLACE(((LTRIM(RTRIM(CONVERT(NUMERIC(38,3),T1.Quantity))))),''.'','''')
+ ''0'' + REPLACE(SPACE(12-LEN(CONVERT(varchar(12), CAST(T1.PriceBefDi AS NUMERIC (38,2))))),'' '', ''0'') + REPLACE(((LTRIM(RTRIM(CONVERT(NUMERIC(38,2),T1.PriceBefDi))))) ,''.'','''')
+ ''ZPHA''
+ '' ''
+ '' ''
+ '' ''
+ ((LTRIM(RTRIM(T4.CardName)))) + SPACE(69-LEN(LTRIM(RTRIM(T4.CardName))))
+ '' ''
+ CONVERT(varchar(10), T0.DocDate, 112)
+ '' ''
FROM
JFOTST.dbo.OINV T0
INNER JOIN JFOTST.dbo.INV1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN JFOTST.dbo.ODLN T2 ON T2.DocNum=T1.BaseRef
INNER JOIN JFOTST.dbo.DLN1 T3 ON T3.DocEntry=T2.DocEntry
INNER JOIN JFOTST.dbo.OCRD T4 ON T1.U_NumConc=T4.AddId
WHERE T0.CardCode=''C52''
queryout "c:\text1.txt" -c -T -x'
Note that in this code everytime you need to use the symbol ' you have to doble it like ''Fixed Text''.
Be aware that there is one UDF so if you try to make this query run in your SB1 you will have to create a UDF called U_NumConc in the document lines.
Database usage:
JFOTST.dbo.OINV T0
JFOTST.dbo - Database Name.
OINV - Table
T0 - Alias
For any doubts I'll be available to help.
Once again thank you very much for all your help.
Together we are stronger!
Kind Regards,
Miguel Barbosa
Edited by: Miguel Barbosa on Aug 18, 2009 12:09 PM
Edited by: Miguel Barbosa on Aug 18, 2009 12:10 PM -
How to effect changes made in a jTable into a text file
i have created a jTable in netbeans6. The table model is DefaultTableModel.
i'm not understanding the concept of firecellupdate and other events listeners.
i want the changes i make to the table during runtime to be written into a Text file.
any help would be greatly appreciated.rishi_86 wrote:
i have created a jTable in netbeans6. The table model is DefaultTableModel.
i'm not understanding the concept of firecellupdate and other events listeners.
i want the changes i make to the table during runtime to be written into a Text file.
any help would be greatly appreciated.you need to add the TableModelListener to your table model.
for example:
model.addTableModelListener(new TableModelListener() {
public void tableChanged(TableModelEvent e) {
// TODO Auto-generated method stub
});then, you need to put your custom business logic(saving data to a text file, etc) into the tableChanged method.
From TableModelEvent you can get all information about the model changes.
Maybe you are looking for
-
How do I stop Firefox from filling in my password?
I want to prevent other people from signing in to websites when they use my computer.
-
Rogue cpu hog while running WebLogic
Hello, My application is a servlet/EJB/Oracle application running on WebLogic. During stress test, I am seeing a java thread that is taking up 50% of available cpu on a dual cpu machine. The thread remains at 100% even after the load is over. Here ar
-
Web site can't be found, also missing guest map now.
Thursday I re-published and all was OK. Today my web address gets the dreaded can't be found page. So I went to my other site to get to my first site (linked) and it goes to the Apple support page. When visiting from my iWeb application it gets to th
-
Alternative for RFC_READ_TABLE FM
Hello All, SAP has asked not to use RFC_READ_TABLE function module (not to be used by SAPu2019s customers) directly or indirectly. Can anybody please suggest me what will be the alternative for this FM. Or what is the replacement for RFC_READ_TABLE F
-
While P.O creation material automatic capture the last Purchase value
Dear all Please guide me for the following : I need a scenario like while creation of new P.O if material already purchase then system automatic capture the last purchase value as per the given material.... Thanks & Regards, Neha