Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

convert base64 to pdf object for pdf reader in android studio

// HazaaZOOZ - java - how to convert base64 to pdf object for pdf reader in android studio - java

case PDF:
    try {
        byte[] pdfAsBytes = Base64.decode(file.getContent(), Base64.DEFAULT);
        File dir = getStorageDir();
        File pdffile = new File(dir, file.getName());
        if(!pdffile.exists())
        {
            pdffile.getParentFile().mkdirs();
            pdffile.createNewFile();
        }
        Files.write(pdfAsBytes, pdffile);
        Intent pdfIntent = new Intent(Intent.ACTION_VIEW);
        pdfIntent.setDataAndType(Uri.fromFile(pdffile), "application/pdf");
        pdfIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        startActivity(pdfIntent);
    } catch (IOException e) {
        e.printStackTrace();
    }

    break;
Comment

PREVIOUS NEXT
Code Example
Java :: Read File and Resource in JUnit Test into Stream 
Java :: make quotation a string 
Java :: check if LinkedList is empyth java 
Java :: How to initialize a 3d array in Java? 
Java :: how to generate random large string in java 
Java :: maths.abs function in java 
Java :: java empty arraylist 
Java :: Java Create a LinkedHashSet 
Java :: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:251) 
Java :: hashmap put 
Java :: date java use fix timezone 
Java :: android java turn off night mode 
Java :: java basic program 
Java :: expression régulière téléphone java 
Java :: java clear scanner 
Java :: Java Find the greatest common divisor of two positive integers. The integers can be large, so you need to find a clever solution. 
Java :: javadoc commands 
Java :: Java Creating a TreeSet 
Java :: string compareto vs equals java 
Java :: java nested static class 
Java :: insert in arraylist 
Java :: What would be the behavior if this() and super() used in a method? 
Java :: Java 7. Converting List<List<Integer to int[][]: 
Java :: tostring java 
Java :: java printwriter create file 
Java :: what is ioexception in java 
Java :: binary tree traversal 
Java :: the java_home environment variable is not defined correctly on mac 
Java :: Java Create a PrintWriter 
Java :: dates in java 8 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =