Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7435263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:02:40+00:00 2026-05-29T10:02:40+00:00

I have searched the forums and found a few threads, but nothing specific to

  • 0

I have searched the forums and found a few threads, but nothing specific to my challenge.

I am reading a SQL table column called “filebytes” which has a datatype of “image”.This “filebytes” column contains a binary encoded file (a pdf in this case). I have extracted the value (see below) as a string, written it to xml and transported the xml over the network. I am stuck where it needs to be decoded back to a human readable file.

Initially I tried using Base64, but then only realised base64 only works with ASCII and not binary, so the file ended up as corrupt once decoded.

I am not sure how to decode it, since my only “input” at the moment is this string, and I am not sure how to properly convert the string to a byte[] and do the decoding.

Any help is greatly appreciated.

Below is the binary data as it appears in SQL, which is extracted as a string:

0x255044462D312E350D0A25B5B5B5B50D0A312030206F626A0D0A3C3C2F547970652F436174616C6F672F50616765732032203020522F4C616E6728656E2D474229202F53747275637454726565526F6F742038203020522F4D61726B496E666F3C3C2F4D61726B656420747275653E3E3E3E0D0A656E646F626A0D0A322030206F626A0D0A3C3C2F547970652F50616765732F436F756E7420312F4B6964735B2033203020525D203E3E0D0A656E646F626A0D0A332030206F626A0D0A3C3C2F547970652F506167652F506172656E742032203020522F5265736F75726365733C3C2F466F6E743C3C2F46312035203020523E3E2F50726F635365745B2F5044462F546578742F496D616765422F496D616765432F496D616765495D203E3E2F4D65646961426F785B20302030203834312E3932203539352E33325D202F436F6E74656E74732034203020522F47726F75703C3C2F547970652F47726F75702F532F5472616E73706172656E63792F43532F4465766963655247423E3E2F546162732F532F537472756374506172656E747320303E3E0D0A656E646F626A0D0A342030206F626A0D0A3C3C2F46696C7465722F466C6174654465636F64652F4C656E677468203133323E3E0D0A73747265616D0D0A789C758EBB0AC2401444FB0BF71FA68CCD3ECC4A56098164B3BE6045F076216DACFCFFD6A4106E230353CD1C0EEC136D6B4BBA8D705D87614C1884C99E3D42842C4C1E6E8D47B34768A2A9211F2687F75617A6A992FC92137A913E5D4B7EC86E86DC99F28AD950BFFF211C4DA81563AAA0A6C825014AC72B1DEDE082897F015F013F293F0D0A656E6473747265616D0D0A656E646F626A0D0A352030206F626A0D0A3C3C2F547970652F466F6E742F537562747970652F54727565547970652F4E616D652F46312F42617365466F6E742F417269616C2F456E636F64696E672F57696E416E7369456E636F64696E672F466F6E7444657363726970746F722036203020522F4669727374436861722033322F4C617374436861722038342F576964746873203135203020523E3E0D0A656E646F626A0D0A362030206F626A0D0A3C3C2F547970652F466F6E7444657363726970746F722F466F6E744E616D652F417269616C2F466C6167732033322F4974616C6963416E676C6520302F417363656E74203930352F44657363656E74202D3231302F436170486569676874203732382F4176675769647468203434312F4D6178576964746820323636352F466F6E74576569676874203430302F58486569676874203235302F4C656164696E672033332F5374656D562034342F466F6E7442426F785B202D363635202D3231302032303030203732385D203E3E0D0A656E646F626A0D0A372030206F626A0D0A3C3C2F417574686F7228526F7279204861696768292F43726561746F7228FEFF004D006900630072006F0073006F0066007400AE0020004F0066006600690063006500200057006F0072006400200032003000300037292F4372656174696F6E4461746528443A323031323032303730383535333529202F4D6F644461746528443A323031323032303730383535333529202F50726F647563657228FEFF004D006900630072006F0073006F0066007400AE0020004F0066006600690063006500200057006F0072006400200032003000300037293E3E0D0A656E646F626A0D0A31332030206F626A0D0A3C3C2F547970652F4F626A53746D2F4E20362F46697273742033362F46696C7465722F466C6174654465636F64652F4C656E677468203135363E3E0D0A73747265616D0D0A789C6D8F4D0A83400C85F78277783798445B3A05F102820CEA4E5C14095DB596E908F5F69D58A185BACADF97F7126610F880FC08269C08161C9333D8C64E868C2C8AC2389D121AD31A67AA1E34C0B82B72ED95659AEC20BC87D88D68650C2BA4F68D1E10C3808DEB96879836F8790C9D1769A6291877F1725FCB789C8AE8367DD67E86B5BC42250B7893AAE7DBB3D717B3AFC39F6D9ABC01665C3E810D0A656E6473747265616D0D0A656E646F626A0D0A31352030206F626A0D0A5B2032373820302030203020302030203020302030203020302030203020302030203020302030203020302030203020302030203020302032373820302030203020302030203020363637203020373232203020363637203020302037323220302030203020302038333320373232203020302030203020363637203631315D200D0A656E646F626A0D0A31362030206F626A0D0A3C3C2F547970652F585265662F53697A652031362F575B2031203420325D202F526F6F742031203020522F496E666F2037203020522F49445B3C31354437323535423842423230323433414234314331454541443545433639443E3C31354437323535423842423230323433414234314331454541443545433639443E5D202F46696C7465722F466C6174654465636F64652F4C656E6774682036363E3E0D0A73747265616D0D0A789C63600082FFFF1981A420030388AA81505BC014E30230C59407A6987920D41BA00850092F0333846281504C100A2AC70A54C9720DC66304F258813C00F4B307760D0A656E6473747265616D0D0A656E646F626A0D0A787265660D0A302031370D0A3030303030303030303820363535333520660D0A30303030303030303137203030303030206E0D0A30303030303030313234203030303030206E0D0A30303030303030313830203030303030206E0D0A30303030303030343136203030303030206E0D0A30303030303030363232203030303030206E0D0A30303030303030373830203030303030206E0D0A30303030303031303034203030303030206E0D0A3030303030303030303920363535333520660D0A3030303030303030313020363535333520660D0A3030303030303030313120363535333520660D0A3030303030303030313220363535333520660D0A3030303030303030313320363535333520660D0A3030303030303030313420363535333520660D0A3030303030303030303020363535333520660D0A30303030303031343934203030303030206E0D0A30303030303031363433203030303030206E0D0A747261696C65720D0A3C3C2F53697A652031372F526F6F742031203020522F496E666F2037203020522F49445B3C31354437323535423842423230323433414234314331454541443545433639443E3C31354437323535423842423230323433414234314331454541443545433639443E5D203E3E0D0A7374617274787265660D0A313930380D0A2525454F460D0A787265660D0A3020300D0A747261696C65720D0A3C3C2F53697A652031372F526F6F742031203020522F496E666F2037203020522F49445B3C31354437323535423842423230323433414234314331454541443545433639443E3C31354437323535423842423230323433414234314331454541443545433639443E5D202F5072657620313930382F5852656653746D20313634333E3E0D0A7374617274787265660D0A323430330D0A2525454F46

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:02:43+00:00Added an answer on May 29, 2026 at 10:02 am
    String data = "255044462D312E350D0A25B5B5B5B50D0A312030206F626A0"
            + "D0A3C3C2F547970652F436174616C6F672F50616765732032203"
            + "020522F4C616E6728656E2D474229202F5374727563745472656"
            + "5526F6F742038203020522F4D61726B496E666F3C3C2F4D61726"
            + "B656420747275653E3E3E3E0D0A656E646F626A0D0A322030206"
            + "F626A0D0A3C3C2F547970652F50616765732F436F756E7420312"
            + "F4B6964735B2033203020525D203E3E0D0A656E646F626A0D0A3"
            + "32030206F626A0D0A3C3C2F547970652F506167652F506172656"
            + "E742032203020522F5265736F75726365733C3C2F466F6E743C3"
            + "C2F46312035203020523E3E2F50726F635365745B2F5044462F5"
            + "46578742F496D616765422F496D616765432F496D616765495D2"
            + "03E3E2F4D65646961426F785B20302030203834312E393220353"
            + "9352E33325D202F436F6E74656E74732034203020522F47726F7"
            + "5703C3C2F547970652F47726F75702F532F5472616E737061726"
            + "56E63792F43532F4465766963655247423E3E2F546162732F532"
            + "F537472756374506172656E747320303E3E0D0A656E646F626A0"
            + "D0A342030206F626A0D0A3C3C2F46696C7465722F466C6174654"
            + "465636F64652F4C656E677468203133323E3E0D0A73747265616"
            + "D0D0A789C758EBB0AC2401444FB0BF71FA68CCD3ECC4A5609816"
            + "4B3BE6045F076216DACFCFFD6A4106E230353CD1C0EEC136D6B4"
            + "BBA8D705D87614C1884C99E3D42842C4C1E6E8D47B34768A2A92"
            + "11F2687F75617A6A992FC92137A913E5D4B7EC86E86DC99F28AD"
            + "950BFFF211C4DA81563AAA0A6C825014AC72B1DEDE082897F015"
            + "F013F293F0D0A656E6473747265616D0D0A656E646F626A0D0A3"
            + "52030206F626A0D0A3C3C2F547970652F466F6E742F537562747"
            + "970652F54727565547970652F4E616D652F46312F42617365466"
            + "F6E742F417269616C2F456E636F64696E672F57696E416E73694"
            + "56E636F64696E672F466F6E7444657363726970746F722036203"
            + "020522F4669727374436861722033322F4C61737443686172203"
            + "8342F576964746873203135203020523E3E0D0A656E646F626A0"
            + "D0A362030206F626A0D0A3C3C2F547970652F466F6E744465736"
            + "3726970746F722F466F6E744E616D652F417269616C2F466C616"
            + "7732033322F4974616C6963416E676C6520302F417363656E742"
            + "03930352F44657363656E74202D3231302F43617048656967687"
            + "4203732382F4176675769647468203434312F4D6178576964746"
            + "820323636352F466F6E74576569676874203430302F584865696"
            + "76874203235302F4C656164696E672033332F5374656D5620343"
            + "42F466F6E7442426F785B202D363635202D32313020323030302"
            + "03732385D203E3E0D0A656E646F626A0D0A372030206F626A0D0"
            + "A3C3C2F417574686F7228526F7279204861696768292F4372656"
            + "1746F7228FEFF004D006900630072006F0073006F0066007400A"
            + "E0020004F0066006600690063006500200057006F00720064002"
            + "00032003000300037292F4372656174696F6E4461746528443A3"
            + "23031323032303730383535333529202F4D6F644461746528443"
            + "A323031323032303730383535333529202F50726F64756365722"
            + "8FEFF004D006900630072006F0073006F0066007400AE0020004"
            + "F0066006600690063006500200057006F0072006400200032003"
            + "000300037293E3E0D0A656E646F626A0D0A31332030206F626A0"
            + "D0A3C3C2F547970652F4F626A53746D2F4E20362F46697273742"
            + "033362F46696C7465722F466C6174654465636F64652F4C656E6"
            + "77468203135363E3E0D0A73747265616D0D0A789C6D8F4D0A834"
            + "00C85F78277783798445B3A05F102820CEA4E5C14095DB596E90"
            + "8F5F69D58A185BACADF97F7126610F880FC08269C08161C9333D"
            + "8C64E868C2C8AC2389D121AD31A67AA1E34C0B82B72ED95659AE"
            + "C20BC87D88D68650C2BA4F68D1E10C3808DEB96879836F8790C9"
            + "D1769A6291877F1725FCB789C8AE8367DD67E86B5BC42250B789"
            + "3AAE7DBB3D717B3AFC39F6D9ABC01665C3E810D0A656E6473747"
            + "265616D0D0A656E646F626A0D0A31352030206F626A0D0A5B203"
            + "2373820302030203020302030203020302030203020302030203"
            + "0203020302030203020302030203020302030203020302030203"
            + "0203237382030203020302030203020302036363720302037323"
            + "2203020363637203020302037323220302030203020302038333"
            + "320373232203020302030203020363637203631315D200D0A656"
             + "E646F626A0D0A31362030206F626A0D0A3C3C2F547970652F585"
            + "265662F53697A652031362F575B2031203420325D202F526F6F7"
            + "42031203020522F496E666F2037203020522F49445B3C3135443"
            + "7323535423842423230323433414234314331454541443545433"
            + "639443E3C3135443732353542384242323032343341423431433"
            + "1454541443545433639443E5D202F46696C7465722F466C61746"
            + "54465636F64652F4C656E6774682036363E3E0D0A73747265616"
            + "D0D0A789C63600082FFFF1981A420030388AA81505BC014E3023"
            + "0C59407A6987920D41BA00850092F0333846281504C100A2AC70"
            + "A54C9720DC66304F258813C00F4B307760D0A656E64737472656"
            + "16D0D0A656E646F626A0D0A787265660D0A302031370D0A30303"
            + "03030303030303820363535333520660D0A30303030303030303"
            + "137203030303030206E0D0A30303030303030313234203030303"
            + "030206E0D0A30303030303030313830203030303030206E0D0A3"
            + "0303030303030343136203030303030206E0D0A3030303030303"
            + "0363232203030303030206E0D0A3030303030303037383020303"
            + "0303030206E0D0A30303030303031303034203030303030206E0"
            + "D0A3030303030303030303920363535333520660D0A303030303"
            + "0303030313020363535333520660D0A303030303030303031312"
            + "0363535333520660D0A303030303030303031322036353533352"
            + "0660D0A3030303030303030313320363535333520660D0A30303"
            + "03030303030313420363535333520660D0A30303030303030303"
            + "03020363535333520660D0A30303030303031343934203030303"
            + "030206E0D0A30303030303031363433203030303030206E0D0A7"
            + "47261696C65720D0A3C3C2F53697A652031372F526F6F7420312"
            + "03020522F496E666F2037203020522F49445B3C3135443732353"
            + "5423842423230323433414234314331454541443545433639443"
            + "E3C3135443732353542384242323032343341423431433145454"
            + "1443545433639443E5D203E3E0D0A7374617274787265660D0A3"
            + "13930380D0A2525454F460D0A787265660D0A3020300D0A74726"
            + "1696C65720D0A3C3C2F53697A652031372F526F6F74203120302"
            + "0522F496E666F2037203020522F49445B3C31354437323535423"
            + "842423230323433414234314331454541443545433639443E3C3"
            + "1354437323535423842423230323433414234314331454541443"
            + "545433639443E5D202F5072657620313930382F5852656653746"
            + "D20313634333E3E0D0A7374617274787265660D0A323430330D0"
            + "A2525454F46";
    
    BigInteger hex = new BigInteger(data.substring(2), 16);
    byte[] byte_data = hex.toByteArray();
    
    ByteArrayInputStream input = new ByteArrayInputStream(byte_data);
    FileOutputStream output = new FileOutputStream(new File("/home/user/file.pdf"));
    
    byte[] buffer = new byte[1024 * 4];
    int n = 0;
    while (-1 != (n = input.read(buffer))) {
        output.write(buffer, 0, n);
    }
    
    output.close();
    input.close();
    

    The file contains TEST : ATTACHMENT

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't understand. I have searched all internet forums but found nothing helpful. I
I have searched far and wide on the Internet but have not found anything
I have searched for two weeks, every night, exhaustively reading forum threads and trying
I have searched for IO issue in forums and found many questions on the
I have searched but apparently my google foo is weak. What I need is
I have searched the Web for this, but with no luck. Any idea? Thanks.
I have searched/Googled around but I'm struggling with the following problem. I am building
I have searched for hours now and haven't found a solution for my problem.
I have searched through stackoverflow and has found similar question. As I am still
I searched the forums but didn't find any answers to this question. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.