How to Print Bytes[] from a resultset in a text file? Thanks a Lot!!

Hi all I'm having a prb in printing the Byte[] from a Resultset in a textfile . Every time I exceute this program different values is printing in the text file and in binary format like:
[B@29c3,[B@347a,[B@3f2f,[B@49e6,[B@549d
and I'm supposed to get the out put as :
0000690D,00002107,00009F16,00003008,0000ED0F
Here is the sample code!
public static void main(String[] args) {
     try {
Class.forName(drvName);
Connection con = DriverManager.getConnection(url, SDR_userName, SDR_passWord);
Statement stmt = con.createStatement();
int count1 = 0;
char c = 'c';
ResultSet rs1 = stmt.executeQuery(_sqlQuery);
FileOutputStream fos = new FileOutputStream(inputFileName);
Writer out = new OutputStreamWriter(fos, "UTF8");
while (rs1.next()) {
byte[] _id = rs1.getBytes(1);
String _name = rs1.getString(2);
out.write("_id=="+id+"==name=="+_name);
int len = sales_account_id.length;
System.out.println("Length==" + len);
String s = new String(_id, 0, len, "UTF8");
char c1[] = s.toCharArray();
for (int i = 0; i < s.length(); i++) {
System.out.print("s1" + c1);
System.out.println("_Id" + s.toString());
try {
for (int i = 0; i < len; i++) {
c = (char) _id;
System.out.println("_Id" + c);
catch (Exception statemets...){}
Thanks a lot in advance!!

out.write("_id=="+id+"==name=="+_name);
in this line you are printing the array _id. when you do that ( print array ) you get the address of that array. so the output is expected.
what you can do is create a new String from the byte array and write that string to the file.
String temp = new String( _id );
out.write("_id=="+temp+"==_name=="+_name);
hope i got your problem right

Similar Messages

  • How to write records from a resultset into a txt file ???

    Hi, I am a newbie in java servlet technology. Currently, I am having a problem regarding how to write all my records from within a resultset into a text file.
    First, I put all my records into a string variable and then append the string into a stringbuffer. After that, I create a bufferoutputstream and used the write method to write into a text file. Below are the code I used in my program.
    Connection connection = null;
    Statement statement = null;
    ResultSet resultset = null;
    // Connect to database
    connection = getConnection();
    StringBuffer str_buf = new StringBuffer();
    statement = connection.createStatement();
    resultset = statement.executeQuery("SELECT * FROM STUDENT");
    String data_row = "";
    str_buf.append("STUDENT_ID,NAME,PHONE,ADDRESS,RESULT");
    while (resultset.next()) {
       data_row = "\n";
       data_row += resultset.getLong("STUDENT_ID");
       data_row += ",\"" + resultset.getString("NAME").trim() + "\"";
       data_row += ",\"" + resultset.getString("PHONE").trim() + "\"";
       data_row += ",\"" + resultset.getString("ADDRESS").trim() + "\"";
       data_row += ",\"" + resultset.getString("RESULT").trim() + "\"";
       str_buf.append(data_row);
    BufferedOutputStream buf_out = null;
    // Create a folder and write all records into info.txt
    String fileName = "student/info.txt";
    buf_out = new BufferedOutputStream(new FileOutputStream(fileName));
    int str_len     = str_buf.length();
    for (int i = 0; i < str_len; i++) {
       buf_out.write(str_buf.charAt(i));
    }So. is this a proper way to write information into a text file ?
    The total records are around 150 000. Now, I get an exception which is "XServletError : System.lang.outofmemory". It happen if the total records are more than 60 000, within a while loop when I try to append a string into a stringbuffer.
    How should I deal with this kind of situation?
    Thanks in advanced and any advice is appreciated. Example is even better to improve understanding.
    Thanks

    Connection connection = null;
    Statement statement = null;
    ResultSet resultset = null;
    // Connect to database
    connection = getConnection();
    StringBuffer str_buf = new StringBuffer();
    String fileName = "student/info.txt";
    FileWriter fw = new FileWriter(fileName);
    statement = connection.createStatement();
    resultset = statement.executeQuery("SELECT * FROM
    STUDENT");
    String data_row = "";
    fw.write("STUDENT_ID,NAME,PHONE,ADDRESS,RESULT");
    while (resultset.next()) {
    data_row = "\n";
    data_row += resultset.getLong("STUDENT_ID");
    data_row += ",\"" + resultset.getString("NAME").trim()
    + "\"";
    data_row += ",\"" +
    resultset.getString("PHONE").trim() + "\"";
    data_row += ",\"" +
    resultset.getString("ADDRESS").trim() + "\"";
    data_row += ",\"" +
    resultset.getString("RESULT").trim() + "\"";
    fw.write(data_row);
    fw.close();

  • How to print the data in a seperate page / text file

    Hi Experts,
    I have created WD program which fetches data from R/3 using RFC. I am using following statement for printing the results:
    wdComponentAPI.getMessageManager().reportSuccess("The value is " + value);
    I am running the code for 20,000 rows. The results are printed on the same IE page. However it becomes difficult to see the results. I want to get the output printed in any of the following ways:
    Option 1
    1) There should be a link in WD program. When the user willl click on the link other IE page should get open and results should be printed in this page.
    Option 2
    2) The ouput should be written in a text file and user can store the file in local machine.
    Please help me.
    Regards,
    Gary

    Just create a function in your WD application that writes these lines (in loop; pass array of strings to the function) on a text file and saved  as a web resource object then have it available for download by the user. Simple as that.
    Search for WD tutorials that involves downloads and using the web resouce object in WD applications.
    This guide should provide you a good feel through the entire approach: /people/bertram.ganz/blog/2007/05/25/new-web-dynpro-java-tutorials--uploading-and-downloading-files-in-sap-netweaver-70

  • How to convert bytes to GB inside of a text file

    I'm using a PS script to automate WSUS cleanup and then output the results to a text file which is then emailed to me.
    The output for Diskspace Freed is displayed in bytes, I would like to convert this to GB, but I am having trouble getting this to work.
    Here is what I was attempting to work with, but it is not working properly (the 2nd line). 
    Get-WsusServer | Invoke-WsusServerCleanup -CleanupObsoleteUpdates -CleanupUnneededContentFiles | Out-File "C:\Users\USER1\Downloads\WSUS Cleanup Log\cleanup $(get-date -f MM-dd-yy).txt"
    #(Get-Content "C:\Users\USER1\Downloads\WSUS Cleanup Log\cleanup $(get-date -f MM-dd-yy).txt") | ForEach-Object {$_."diskspace free" / 1MB} | Set-Content "C:\Users\USER1\Downloads\WSUS Cleanup Log\cleanup $(get-date -f MM-dd-yy).txt""C:\WSUS PS Script\cleanup $(get-date -f MM-dd-yy).txt"
    Send-MailMessage -to [email protected] -Subject "WSUS Cleanup" -Attachments "C:\Users\USER1\Downloads\WSUS Cleanup Log\cleanup $(get-date -f MM-dd-yy).txt" -SmtpServer 192.X.X.X -from [email protected]

    Hi Granite,
    I've got to guess here - don't have a handy 2012R2 Wsus Server at hand and I'm extrapolating from the Technet Library's documentation example output for Invoke-WsusServerCleanup - but this is what I came up with:
    $File = "C:\Users\USER1\Downloads\WSUS Cleanup Log\cleanup $(get-date -f MM-dd-yy).txt"
    $Script = {
    if ($_ -match "diskspace free")
    $Bytes = ($_.Trim().Split(":") | Select -Last 1).Trim()
    $String = ($_.Trim().Split(":") | Select -First 1).Trim() + ": "
    $String += "{0:n3}" -f ($Bytes / 1GB)
    $String += "GB"
    $String
    else { $_ }
    Get-WsusServer | Invoke-WsusServerCleanup -CleanupObsoleteUpdates -CleanupUnneededContentFiles | ForEach-Object $script | Out-File $File
    Send-MailMessage -to [email protected] -Subject "WSUS Cleanup" -Attachments $File -SmtpServer 192.X.X.X -from [email protected]
    If this doesn't work out for you, please post the actual output of the Cleanup Command.
    Cheers,
    Fred
    There's no place like 127.0.0.1
    Thanks for the response, this is exactly what I was looking for!
    The script ran with no errors. The output does show as GB, however since the script was already ran today there value is currently 0. I will test this again in a couple of days.

  • How to save XML from a CLOB to  a text file (size over 32767 chars)

    Hi,
    I am trying to export a table into an XML file. Using various examples, I have learned that is really easy to handle objects smaller that 32767 bytes (characters).
    The problem is working with big chunks. My XML CLOB is just over 10 MB in size. I can easilly break it into smaller pieces but then I risk to write chr(10) in the middle of a XML Tag (which happened). I have an idea of finding a way around the problem but there are two issues:
    1. DBMS_LOB.instr function returns 0 if offset grows above appx 1100.
    2. I tried this in oreder to avid the limitation from item 1.:
    for c = 1..dbms_lob.getlength(CLOB) loop
    dbms_lob.read(CLOB,c,1,MyString);
    if MyString = chr(10) then
    utl_file.put_line(MyLine);
    MyLine := '';
    else
    MyLine := MyLine || MyString;
    end if;
    end loop;
    This way I generate perfect XML structure, and it takes about an hour of cpu time to create 2.3 MB file. I have tried to run ir for a big one, and it took just over 7 hours to get to 10.2 MB when I had shut it down.
    Does anybody has any suggestions?

    supahsain08 wrote:
    Well, you are not in my class and you don't even know my teacher
    who are you to judge meHe is jaded by our experiences here. 99% of posters who complain that the teacher doesn't teach have adequate (note that I didn't say good) teachers, but it's the student who is failing to take responsibility for his own education. It is after all your responsibility and complaining won't help you any.
    Good luck.

  • How to print photos from my iphone?

    I have the HP Photosmart C309a,(wireless) and would like to know how to print photos from my iphone 3G.
    I have the "app" "HP ePrint Home & Biz", but I don't know if it's compatible with my printer?

    The app is compatible with your printer IF it is connected to a network (not via USB to a printer).
    If it is not working restart your router by pulling its power plug momentarily.
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • How to print information from my Apple I pad to my HP Photosmart D110 series printer

    How to print information from my Apple I Pad to my HP Photosmart D110 series printer ?

    Hello 518,
    Welcome to the HP Support Forums!
    It would appear that the HP Photosmart Plus 209B is not compatible with AirPrint. Without AirPrint you can only print via an App.
    I suggest the ePrint App. Getting Started with HP ePrint Mobile Apps<---
    Cheers,
    JERENDS
    I work on behalf of HP
    Please click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" to the left of the reply button to say “Thanks” for helping!

  • How to print labels from my Christmas card list?

    Does anyone know how to print labels from the Christmas card list in Contacts?
    I am new to computers and having managed to type in all my addresses I was hoping to print some labels!    Please can anyone help!

    Welcome to the Support Communities. What version of OS X is your Mac running? ...Click on the  menu at top left of your screen and choose About This Mac. Note the version in the form 10.n.n and then see this ASC tutorial:
    Update your product list
    Then see this Apple doc, which is for OS X 10.9 (Mavericks)...
    Contacts (Mavericks): Print contact information
    ...Found by searching here:
    http://support.apple.com/kb/index?page=search

  • How to Print directly from forms...please help me...

    Hi
    I have a base table block in a form (forms 5.0).
    and this form we use for entering transactions.
    Once transaction is entered and saved. To print this transaction I call a report (report writer 3.0). Here to print this transaction we have two steps entering in a form and then call a report after report generation printing..
    Instead of this I want to give a Print button in the form itself and when I click the print button it should directly goto printer dialogbox.
    How do I do this?
    Thanks

    Hi,
    Open a text file in Read mode and write all ur transactions into it.
    After that,u can use host like(In W-B-P trigger)
    host('type textname > prn)
    Hope this helps..
    Prashanth Deshmukh

  • How do I convert my Voice Memo from iPhone 5s to a text file?

    How do I convert my Voice Memo from iPhone 5s to a text file?

    If you have Evernote, you could try quicktate.   http://www.quicktate.com
    I convert voice memos on my Mac using the Dictation feature:
    Open TextEdit on a new document
    Enable  Dictation & Speech enabled the System Preferences.
    Press the fn-key twice
    Play the voice memo on the iPhone and let the  Mac listen to it using the internal microphone with TextEdit open on a new document.
    Press the fn-key twice, to finish Dictation.  You will only see the transcribed text, when Dictation has finished.

  • How do I populate the choices in a Combo Box in a PDF Form from an Excel spreadsheet or text file?

    Pleasel let me know if there is a way to copy and paste choices for a Combo Box from an Excel spreadsheet or text file.  I have over 250 values I'd like to add and don't trust my typing!
    Thanks for the help!
    Ken K. - 2191

    Yes, using the field.getItemAt method: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.745.html
    E.g.:
    var aItems = [];
    var f = getField("combo1");
    for (var i = 0; i < f.numItems; i++) {
        aItems[i] = f.getItemAt(i);
    If there are export values you need to decide how to use the optional bExportValue parameter.

  • I am new sto Lightroom and have also just changed from Apple to PC.  I cannot figure out how to download photos from the Photoshop library to a file that will be sent to MPIX for processing.  Also, does Lightroom have an easy access to a photo processing

    I am new to Lightroom and have also just changed from Apple to PC.  I cannot figure out how to download photos from the Photoshop library to a file that will be sent to MPIX for processing.  Also, does Lightroom have an easy access to a photo processing capability such as MPIX?

    Use the trackpad to scroll, thats what it was designed for. The scroll bars automatically disappear when not being used and will appear if you scroll up or down using the trackpad.
    This is a user-to-user forum and most people will post on here if they have problems. You very rarely get people posting to say there update went smooth. The fact is the vast majority of Mountain Lion users will not be experiencing any major problems with the OS, or maybe with apps which are not compatible, but thats hardly Apple's fault if developers don't update their apps.

  • How Do You Write Thermocouple Readings From Multiple Channels to One Text File?

    Hi Everyone,
    I am having difficulty writing a Labview program that allows me to combine readings taken from 8 thermocouples to one text file. I am using a NI cDAQ - 9174 with NI 9219 modules.
    Attached is a copy of my program thus far. I have figured out how to combine readings from 8 thermocouples to one waveform chart but the text file will infact be more vital.
    I am very new to Labview and only require it for this task so the simpler the solution the better. Apologies for the lack of technical language.
    Any help would be much appreciated.
    Amy

    Here's one simple possibility...
    Of course, this shows incomplete file handling, and you'll probably want to truncate your floating point values to a few decimal places. I have used this kind of operations for generating text and csv files for thermocouples, much like you are doing.
    Good luck!
    Dan

  • How can we generate the reports in html or text file formats?

    Hi,
    Is there any package that can help in creating HTMLDB reports in .txt files or .html files? (Similar to TEXT_IO in Oracle Forms)
    How can we generate the reports in html or text file formats from HTMLDB?
    Thanks in Advance
    Renjith

    Hello all.
    Bi Publisher is great, but has a very high price tag. It's even more expensive than Forms & Reports Services. We are considering APEX to replace Forms & Reports on the web, but the reporting limitations are still a problem.
    I wonder if there is another option.
    Thanks

  • Data from transactional cube to a text file in directories

    hi all
    i have 2 transactional planning cubes in BW. the data in these cubes in bw needs to be uploaded monthly in to a single text file so that APO system can access the data for some purpose.
    my question is how to upload the data from transactional cubes to the text file, which is more detailed. is that use ful to construct a ODS or CUBE(basic) on top of the transactional cubes.
    if i keep the file in BW directory whethere APO can access that.?..
    please help me out
    praveen.

    Hello PraVeeN,
    How r u ?
    Is this not possible with InfoSpokes ???
    Best Regards....
    Sankar Kumar
    +91 98403 47141

Maybe you are looking for

  • Bookmark "star" in URL bar is not working

    I'm clicking on the "star" to bookmark this page. It is not working and doesnt seem to be doing anything. The star shows it's animation on click, but does not allow me to save a bookmark.

  • How to create board game in InDesign

    I am trying to create a board game in InDesign, similar to the trivial pursuit board game. In other words, an outer wheel that has been divided up in sectionsand then spoes to the center. I think I can figure out how to do the spoes and the center, b

  • Cfmail sending double attachments.

    Hello; I wrote a cfmail app that allows you to send one attachment. Everything about it works fine. The problem is, it's sending 2 of the uploaded image and I can't figure out why. I'm not going to put in all my error code and so on, I'm just showing

  • Reg:user-exits

    hi to all , iam new to user-exits.i had seen some user-exits. in which some are like FUNCTION EXIT_SAPMV45A_002, FORM USEREXIT_FIELD_MODIFICATION.so what is the difference between them are there any more exits. with regards satish

  • Large documents

    Employer sent schedule on spreadsheet through email. Tried to synch spreadsheet into tx but cells,columns way to big- 2 cells took up almost the whole tx screen. Is there a program that can resize documents,spreadsheets for tx Post relates to: Palm T