List of usage examples for java.io DataInputStream available
public int available() throws IOException
From source file:Main.java
public static void main(String[] args) throws IOException { short[] s = { 123, 234 }; FileOutputStream fos = new FileOutputStream("c:\\test.txt"); DataOutputStream dos = new DataOutputStream(fos); for (short j : s) { dos.writeShort(j);/* w w w . ja v a 2 s. c o m*/ } dos.flush(); InputStream is = new FileInputStream("c:\\test.txt"); DataInputStream dis = new DataInputStream(is); while (dis.available() > 0) { short k = dis.readShort(); System.out.print(k); } }
From source file:Main.java
public static void main(String[] args) throws IOException { byte[] buf = { 65, 66, 67, 68, 69, 70 }; FileOutputStream fos = new FileOutputStream("c:\\test.txt"); DataOutputStream dos = new DataOutputStream(fos); for (byte b : buf) { dos.writeChar(b);/*from w ww . j av a2 s . c o m*/ } dos.flush(); InputStream is = new FileInputStream("c:\\test.txt"); DataInputStream dis = new DataInputStream(is); while (dis.available() > 0) { char c = dis.readChar(); System.out.print(c); } }
From source file:Main.java
public static void main(String[] args) throws IOException { double[] dbuf = { 65.56, 66.89, 67.98, 68.82, 69.55, 70.37 }; FileOutputStream fos = new FileOutputStream("c:\\test.txt"); DataOutputStream dos = new DataOutputStream(fos); for (double d : dbuf) { dos.writeDouble(d);// ww w.j a v a 2 s . c om } dos.flush(); InputStream is = new FileInputStream("c:\\test.txt"); DataInputStream dis = new DataInputStream(is); while (dis.available() > 0) { double c = dis.readDouble(); System.out.print(c + " "); } }
From source file:TestEOF.java
public static void main(String[] args) throws IOException { DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream("TestEOF.java"))); while (in.available() != 0) System.out.print((char) in.readByte()); }
From source file:Version2LicenseDecoder.java
public static void main(String[] args) throws IOException, Exception { new Version2LicenseDecoder(); String lll = "AAABDA0ODAoPeNptUEtPg0AQvu+vIPG8ZsEKlmQPFda6DVAENB68rHTUbdotmQVi/71QTHykh5lM5nvMl7m4Q+2sOuOwwGHz8PomnDFnmVaOx9wrEoOtUTetPhi+ksXiJXREr3adGjckQjgNsWqBj3zKfMoCstWoLhNdg7EgNvqkFlkliryQpSA/DrzFDv7Qq2MDmdoDj9ZpKopILpIJV3Wre5gEu4n7BGhHE4+kSpsWjDI1iM9G4/FXomBMtMZ3ZbSdjm4PWpnN0M1knXX7V8D126MdDDl1SQnYA8qY31b5A5WRLKgfP0d0du8uSSkyPhRNPJ/5njcn38kHeiLjc8j5SHmH9Yey8P95XxVof60wKwITfDIxHZPgo323OEKd2FJ4BXvU7wIUIbLvXQNrkIAf4AL2Aeu4ZBRbTOA=X02dl"; String lls = "AAABckRlc2NyaXB0aW9uPUpJUkE6IENvbW1lcmNpYWwKQ3JlYXRpb25EYXRlPTIwMTMtMDYtMDcKamlyYS5MaWNlbnNlRWRpdGlvbj1FTlRFUlBSSVNFCkV2YWx1YXRpb249ZmFsc2UKamlyYS5MaWNlbnNlVHlwZU5hbWU9Q09NTUVSQ0lBTApqaXJhLmFjdGl2ZT10cnVlCmxpY2Vuc2VWZXJzaW9uPTIKTWFpbnRlbmFuY2VFeHBpcnlEYXRlPTIwOTktMDYtMDcKT3JnYW5pc2F0aW9uPWpvaWFuZGpvaW4KU0VOPVNFTi1MMjYwNjIyOQpTZXJ2ZXJJRD1CVFBRLUlDSVItNkRYQy00SDFHCmppcmEuTnVtYmVyT2ZVc2Vycz0tMQpMaWNlbnNlSUQ9TElEU0VOLUwyNjA2MjI5CkxpY2Vuc2VFeHBpcnlEYXRlPTIwOTktMDYtMDcKUHVyY2hhc2VEYXRlPTIwMTMtMDYtMDc=X02g4"; // String sll = "Description=JIRA:Commercial\nCreationDate=2013-06-07\njira.LicenseEdition=ENTERPRISE\nEvaluation=false\njira.LicenseTypeName=COMMERCIAL\njira.active=true\nlicenseVersion=2\nMaintenanceExpiryDate=2099-06-07\nOrganisation=joiandjoin\nSEN=SEN-L2606229\nServerID=BTPQ-ICIR-6DXC-4H1G\njira.NumberOfUsers=-1\nLicenseID=LIDSEN-L2606229\nLicenseExpiryDate=2099-06-07\nPurchaseDate=2013-06-07"; // String sll = "com.allenta.jira.plugins.gitlab.gitlab-listener.enterprise=true\nDescription=GitLab Listener\\: Evaluation\nNumberOfUsers=-1\nCreationDate=2015-12-29\nContactEMail=xwturing@gmail.com\nEvaluation=true\ncom.allenta.jira.plugins.gitlab.gitlab-listener.Starter=false\nlicenseVersion=2\nMaintenanceExpiryDate=2099-01-27\nOrganisation=Evaluation license\nSEN=SEN-L7030895\ncom.allenta.jira.plugins.gitlab.gitlab-listener.active=true\nLicenseExpiryDate=2099-01-27\nLicenseTypeName=COMMERCIAL\nPurchaseDate=2015-12-29\n"; // String sll = "jira.product.jira-servicedesk.active=true\njira.product.jira-servicedesk.Starter=false\nNumberOfUsers=-1\nPurchaseDate=2016-01-05\ncom.atlassian.servicedesk.active=true\nLicenseTypeName=COMMERCIAL\nLicenseExpiryDate=2099-02-03\nContactEMail=xwturing@gmail.com\nServerID=BWGW-FKTG-N1UQ-PNHH\ncom.atlassian.servicedesk.LicenseTypeName=COMMERCIAL\njira.product.jira-servicedesk.NumberOfUsers=-1\nMaintenanceExpiryDate=2099-02-03\ncom.atlassian.servicedesk.enterprise=true\nLicenseID=LIDSEN-L7059162\nSEN=SEN-L7059162\nOrganisation=Evaluation license\nCreationDate=2016-01-05\ncom.atlassian.servicedesk.numRoleCount=-1\nlicenseVersion=2\nDescription=JIRA Service Desk (Server)\\: Evaluation\nEvaluation=true"; String sll = "NumberOfUsers=-1\n" + "jira.product.jira-core.NumberOfUsers=-1\n" + "jira.NumberOfUsers=-1\n" + "PurchaseDate=2016-02-20\n" + "LicenseTypeName=COMMERCIAL\n" + "LicenseExpiryDate=2099-03-21\n" + "ContactEMail=xwturing@gmail.com\n" + "ServerID=BVDW-Q5Y0-CRXH-AI3I\n" + "jira.product.jira-core.Starter=false\n" + "jira.LicenseEdition=ENTERPRISE\n" + "jira.product.jira-core.active=true\n" + "MaintenanceExpiryDate=2099-03-21\n" + "LicenseID=LIDSEN-L7336401\n" + "SEN=SEN-L7336401\n" + "Organisation=Evaluation license\n" + "CreationDate=2016-02-20\n" + "licenseVersion=2\n" + "Description=JIRA Core (Server)\\: Evaluation\n" + "jira.active=true\n" + "jira.LicenseTypeName=COMMERCIAL\n" + "Evaluation=true"; byte[] allData = sll.getBytes(); Signature signature = Signature.getInstance("SHA1withDSA"); signature.initVerify(PUBLIC_KEY);/*from w w w .jav a 2s. c o m*/ signature.update(allData); ByteArrayInputStream in = new ByteArrayInputStream(allData); DataInputStream dIn = new DataInputStream(in); int textLength = dIn.readInt(); byte[] licenseText = new byte[textLength]; dIn.read(licenseText); byte[] hash = new byte[dIn.available()]; dIn.read(hash); String result = packLicense(allData, hash); System.out.println(result); }
From source file:Main.java
/** * @param context//from w ww.j a v a 2s. c o m * @param filePath file path relative to assets, like request_init1/search_index.json * @return */ public static String readAssert(Context context, String filePath) { try { if (filePath.startsWith(File.separator)) { filePath = filePath.substring(File.separator.length()); } AssetManager assetManager = context.getAssets(); InputStream inputStream = assetManager.open(filePath); DataInputStream stream = new DataInputStream(inputStream); int length = stream.available(); byte[] buffer = new byte[length]; stream.readFully(buffer); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); byteArrayOutputStream.write(buffer); stream.close(); return byteArrayOutputStream.toString(); } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:org.nuxeo.theme.styling.service.palettes.PaletteParser.java
public static Map<String, String> parse(InputStream in, String filename) throws IOException, PaletteParseException { DataInputStream dis = new DataInputStream(in); byte[] bytes = new byte[dis.available()]; dis.read(bytes);/* ww w. j ava 2 s .co m*/ return parse(bytes, filename); }
From source file:FileUtil.java
public static byte[] readFileAsBytes(String path, Integer start, Integer length) { byte[] byteData = null; try {//from w w w. j ava2 s .co m File file = new File(path); DataInputStream dis; dis = new DataInputStream(new FileInputStream(file)); if (dis.available() > Integer.MAX_VALUE) { System.out.println("dis.available() > Integer.MAX_VALUE"); } ByteArrayOutputStream os = new ByteArrayOutputStream(length); byte[] bytes = new byte[length]; dis.skipBytes(start); int readBytes = dis.read(bytes, 0, length); os.write(bytes, 0, readBytes); byteData = os.toByteArray(); dis.close(); os.close(); } catch (Exception e) { System.out.println(e); } return byteData; }
From source file:ImportKey.java
/** * <p>/* w w w . j a v a 2 s .c o m*/ * Creates an InputStream from a file, and fills it with the complete file. * Thus, available() on the returned InputStream will return the full number * of bytes the file contains * </p> * * @param fname * The filename * @return The filled InputStream * @exception IOException * , if the Streams couldn't be created. **/ private static InputStream fullStream(String fname) throws IOException { FileInputStream fis = new FileInputStream(fname); DataInputStream dis = new DataInputStream(fis); byte[] bytes = new byte[dis.available()]; dis.readFully(bytes); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); return bais; }
From source file:org.nuxeo.theme.presets.PaletteParser.java
public static Map<String, String> parse(InputStream in, String filename) throws IOException, PaletteIdentifyException, PaletteParseException { DataInputStream dis = new DataInputStream(in); byte[] bytes = new byte[dis.available()]; dis.read(bytes);/* w ww .jav a 2 s . co m*/ return parse(bytes, filename); }