Android Open Source - android-pkpass-viewer File Reader






From Project

Back to project page android-pkpass-viewer.

License

The source code is released under:

MIT License

If you think the Android project android-pkpass-viewer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.manso.mytickets.utils;
//from   w  w  w . j av a2  s. c o m
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class FileReader {
  private static final int BUFFER_SIZE = 8192;

  public String readTextFile(File file) throws IOException {      
    BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"),BUFFER_SIZE);    
    try {
      StringBuffer stringBuffer = new StringBuffer();      
      String str;
      while ((str = br.readLine()) != null) {
        stringBuffer.append(str);
      }      
      return stringBuffer.toString();
    } finally {      
      br.close();
    }
  }
  
  public byte[] readBinaryFile(File file) throws IOException {
    FileInputStream fis = new FileInputStream(file);
    
    try {
      ByteArrayOutputStream stream = new ByteArrayOutputStream();
      byte[] buffer = new byte[1024];
      
      int len;
      while ((len = fis.read(buffer)) > 0) {
        stream.write(buffer, 0, len);
      }
      
      byte[] output = stream.toByteArray();
      stream.close();
      return output;
    } finally {
      fis.close();
    }
  }
}




Java Source Code List

com.manso.mytickets.HandleIntentAsyncTask.java
com.manso.mytickets.TicketBackFragment.java
com.manso.mytickets.TicketFrontFragment.java
com.manso.mytickets.ViewTicketFrontActivity.java
com.manso.mytickets.services.EventTicketPassStrategy.java
com.manso.mytickets.services.IPassStrategy.java
com.manso.mytickets.services.ManifestService.java
com.manso.mytickets.services.PassReadingService.java
com.manso.mytickets.services.PassStorageService.java
com.manso.mytickets.services.PassStrategyService.java
com.manso.mytickets.services.PassTypes.java
com.manso.mytickets.utils.BarcodeEncoder.java
com.manso.mytickets.utils.FileReader.java
com.manso.mytickets.utils.ImageUtils.java
com.manso.mytickets.utils.RandomNameGenerator.java
com.manso.mytickets.utils.Sha1.java