Java Code Examples for java.io.IOException#toString()
The following examples show how to use
java.io.IOException#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SM2X509CertImpl.java From julongchain with Apache License 2.0 | 6 votes |
public void sm2Sign(IKey privateKey, AlgorithmId algorithmId) throws JulongChainException, CertificateException { if (isReadOnly()) { throw new CertificateEncodingException("cannot over-write existing certificate"); } try { this.algId = algorithmId; DerOutputStream signedCert = new DerOutputStream(); DerOutputStream signedData = new DerOutputStream(); this.info.encode(signedData); byte[] signedBytes = signedData.toByteArray(); this.algId.encode(signedData); this.signature = CspHelper.getCsp().sign(privateKey, signedBytes, new SM2SignerOpts()); signedData.putBitString(this.signature); signedCert.write((byte)48, signedData); setSignedCert(signedCert.toByteArray()); setReadOnly(true); } catch (IOException e) { throw new CertificateEncodingException(e.toString()); } }
Example 2
Source File: X509CertificateObject.java From TorrentEngine with GNU General Public License v3.0 | 6 votes |
public byte[] getTBSCertificate() throws CertificateEncodingException { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); DEROutputStream dOut = new DEROutputStream(bOut); try { dOut.writeObject(c.getTBSCertificate()); return bOut.toByteArray(); } catch (IOException e) { throw new CertificateEncodingException(e.toString()); } }
Example 3
Source File: LocalTreeNodeHandler.java From ghidra with Apache License 2.0 | 6 votes |
private void handleFileDrag(DomainFolder destFolder, int dropAction, DomainFile file, TaskMonitor monitor) { if (dropAction == DnDConstants.ACTION_COPY || !file.isInWritableProject()) { CopyTask task = new CopyTask(destFolder, file); task.run(monitor); return; } try { file.moveTo(destFolder); } catch (IOException e) { String msg = e.getMessage(); if (msg == null) { msg = e.toString(); } Msg.showError(this, dataTree, "Cannot Move File", "Move file " + file.getName() + " failed.\n" + msg); } }
Example 4
Source File: EditorTestLookup.java From netbeans with Apache License 2.0 | 6 votes |
private static void createFileOnPath(File mountPoint, String path) throws IOException{ mountPoint.mkdir(); File f = new File (mountPoint, path); if (f.isDirectory() || path.endsWith("/")) { f.mkdirs(); } else { f.getParentFile().mkdirs(); try { f.createNewFile(); } catch (IOException iex) { throw new IOException ("While creating " + path + " in " + mountPoint.getAbsolutePath() + ": " + iex.toString() + ": " + f.getAbsolutePath()); } } }
Example 5
Source File: ClassHierarchy.java From tascalate-javaflow with Apache License 2.0 | 5 votes |
private String calculateCommonSuperClass(final String type1, final String type2) { try { TypeInfo info1 = getTypeInfo(type1); TypeInfo info2 = getTypeInfo(type2); // Fast check without deep loading of info2 if (info1.isSubclassOf(info2)) { return type2; } // The reverse, now both will be loaded if (info2.isSubclassOf(info1)) { return type1; } // Generic (worst) case -- flattening hierarchies List<TypeInfo> supers1 = info1.flattenHierarchy(); List<TypeInfo> supers2 = info2.flattenHierarchy(); // Matching from the most specific to least specific for (TypeInfo a : supers1) { for (TypeInfo b : supers2) { if (a.equals(b)) { return a.name; } } } return OBJECT.name; } catch (IOException e) { throw new RuntimeException(e.toString()); } }
Example 6
Source File: PKCS10CertificationRequest.java From ripple-lib-java with ISC License | 5 votes |
/** * return a DER encoded byte array representing this object */ public byte[] getEncoded() { try { return this.getEncoded(ASN1Encoding.DER); } catch (IOException e) { throw new RuntimeException(e.toString()); } }
Example 7
Source File: RabbitMQSink.java From rabbitmq-flume-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
private Channel createRabbitMQChannel() throws EventDeliveryException { try { return connection.createChannel(); } catch (IOException ex) { closeRabbitMQConnection(); throw new EventDeliveryException(ex.toString()); } }
Example 8
Source File: X509CertificatePair.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Return the DER encoded form of the certificate pair. * * @return The encoded form of the certificate pair. * @throws CerticateEncodingException If an encoding exception occurs. */ public byte[] getEncoded() throws CertificateEncodingException { try { if (encoded == null) { DerOutputStream tmp = new DerOutputStream(); emit(tmp); encoded = tmp.toByteArray(); } } catch (IOException ex) { throw new CertificateEncodingException(ex.toString()); } return encoded; }
Example 9
Source File: ResourceBasedPeriodFormatterDataService.java From j2objc with Apache License 2.0 | 5 votes |
/** * Constructs the service. */ private ResourceBasedPeriodFormatterDataService() { List<String> localeNames = new ArrayList<String>(); // of String InputStream is = ICUData.getRequiredStream(getClass(), PATH + "index.txt"); try { BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8")); String string = null; while (null != (string = br.readLine())) { string = string.trim(); if (string.startsWith("#") || string.length() == 0) { continue; } localeNames.add(string); } br.close(); } catch (IOException e) { throw new IllegalStateException("IO Error reading " + PATH + "index.txt: " + e.toString()); } finally { try { is.close(); } catch (IOException ignored) { } } availableLocales = Collections.unmodifiableList(localeNames); }
Example 10
Source File: ImageTools.java From MtgDesktopCompanion with GNU General Public License v3.0 | 5 votes |
public static BufferedImage fromByteArray(byte[] imagebytes) { try { if (imagebytes != null && (imagebytes.length > 0)) { return ImageIO.read(new ByteArrayInputStream(imagebytes)); } return null; } catch (IOException e) { throw new IllegalArgumentException(e.toString()); } }
Example 11
Source File: WebServerTask.java From datacollector with Apache License 2.0 | 5 votes |
@Override public void processRegistrationResponse(RegistrationResponseJson response) { LOG.info("Received registration command from Control Hub"); // Propagate new configuration try { if(!response.getConfiguration().isEmpty()) { RuntimeInfo.storeControlHubConfigs(runtimeInfo, response.getConfiguration()); conf.set(response.getConfiguration()); } } catch (IOException e) { throw new RuntimeException(e.toString(), e); } }
Example 12
Source File: Offset.java From datacollector with Apache License 2.0 | 5 votes |
public String getOffsetString() throws StageException { Map<String, String> map = new HashMap<>(); map.put(POS, getOffset()); try { return OffsetUtil.serializeOffsetMap(map); } catch (IOException ex) { throw new StageException(Errors.SPOOLDIR_33, ex.toString(), ex); } }
Example 13
Source File: DelegationTokenManager.java From hadoop with Apache License 2.0 | 5 votes |
public void init() { if (managedSecretManager) { try { secretManager.startThreads(); } catch (IOException ex) { throw new RuntimeException("Could not start " + secretManager.getClass() + ": " + ex.toString(), ex); } } }
Example 14
Source File: FooTag.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public int doAfterBody() throws JspException { try { if (i == 3) { bodyOut.writeOut(bodyOut.getEnclosingWriter()); return SKIP_BODY; } pageContext.setAttribute("member", atts[i]); i++; return EVAL_BODY_BUFFERED; } catch (IOException ex) { throw new JspTagException(ex.toString()); } }
Example 15
Source File: cfQueryResultData.java From openbd-core with GNU General Public License v3.0 | 5 votes |
public static cfStringData getAsCfStringData( ResultSet _result, int _index ) throws SQLException { Reader inr = _result.getCharacterStream( _index ); if ( !_result.wasNull() ) { try { return cfStringData.getString( inr ); } catch ( IOException e ) { throw new SQLException( e.toString() ); } }else{ return null; } }
Example 16
Source File: SavingRingDataStore.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Constructor * * @param nSamples Capacity of the sample ringbuffer. * @param nEvents Capacity of the event ringbuffer. */ public SavingRingDataStore(final int nSamples, final int nEvents) { super(nSamples, nEvents); savePathRoot = "."; // record the root of the save path try { initFiles(savePathRoot); } catch ( IOException ex ) { throw new IllegalStateException(ex.toString()); } }
Example 17
Source File: X509CertificatePair.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Return the DER encoded form of the certificate pair. * * @return The encoded form of the certificate pair. * @throws CerticateEncodingException If an encoding exception occurs. */ public byte[] getEncoded() throws CertificateEncodingException { try { if (encoded == null) { DerOutputStream tmp = new DerOutputStream(); emit(tmp); encoded = tmp.toByteArray(); } } catch (IOException ex) { throw new CertificateEncodingException(ex.toString()); } return encoded; }
Example 18
Source File: X509CertImpl.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Creates an X.509 certificate, and signs it using the given key * (associating a signature algorithm and an X.500 name). * This operation is used to implement the certificate generation * functionality of a certificate authority. * * @param key the private key used for signing. * @param algorithm the name of the signature algorithm used. * @param provider the name of the provider. * * @exception NoSuchAlgorithmException on unsupported signature * algorithms. * @exception InvalidKeyException on incorrect key. * @exception NoSuchProviderException on incorrect provider. * @exception SignatureException on signature errors. * @exception CertificateException on encoding errors. */ public void sign(PrivateKey key, String algorithm, String provider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException { try { if (readOnly) throw new CertificateEncodingException( "cannot over-write existing certificate"); Signature sigEngine = null; if ((provider == null) || (provider.length() == 0)) sigEngine = Signature.getInstance(algorithm); else sigEngine = Signature.getInstance(algorithm, provider); sigEngine.initSign(key); // in case the name is reset algId = AlgorithmId.get(sigEngine.getAlgorithm()); DerOutputStream out = new DerOutputStream(); DerOutputStream tmp = new DerOutputStream(); // encode certificate info info.encode(tmp); byte[] rawCert = tmp.toByteArray(); // encode algorithm identifier algId.encode(tmp); // Create and encode the signature itself. sigEngine.update(rawCert, 0, rawCert.length); signature = sigEngine.sign(); tmp.putBitString(signature); // Wrap the signed data in a SEQUENCE { data, algorithm, sig } out.write(DerValue.tag_Sequence, tmp); signedCert = out.toByteArray(); readOnly = true; } catch (IOException e) { throw new CertificateEncodingException(e.toString()); } }
Example 19
Source File: Configuration.java From aeron with Apache License 2.0 | 4 votes |
/** * Validate that the socket buffer lengths are sufficient for the media driver configuration. * * @param ctx to be validated. */ public static void validateSocketBufferLengths(final MediaDriver.Context ctx) { try (DatagramChannel probe = DatagramChannel.open()) { final int defaultSoSndBuf = probe.getOption(StandardSocketOptions.SO_SNDBUF); probe.setOption(StandardSocketOptions.SO_SNDBUF, Integer.MAX_VALUE); final int maxSoSndBuf = probe.getOption(StandardSocketOptions.SO_SNDBUF); if (maxSoSndBuf < ctx.socketSndbufLength()) { System.err.format( "WARNING: Could not get desired SO_SNDBUF, adjust OS to allow %s: attempted=%d, actual=%d%n", SOCKET_SNDBUF_LENGTH_PROP_NAME, ctx.socketSndbufLength(), maxSoSndBuf); } probe.setOption(StandardSocketOptions.SO_RCVBUF, Integer.MAX_VALUE); final int maxSoRcvBuf = probe.getOption(StandardSocketOptions.SO_RCVBUF); if (maxSoRcvBuf < ctx.socketRcvbufLength()) { System.err.format( "WARNING: Could not get desired SO_RCVBUF, adjust OS to allow %s: attempted=%d, actual=%d%n", SOCKET_RCVBUF_LENGTH_PROP_NAME, ctx.socketRcvbufLength(), maxSoRcvBuf); } final int soSndBuf = 0 == ctx.socketSndbufLength() ? defaultSoSndBuf : ctx.socketSndbufLength(); if (ctx.mtuLength() > soSndBuf) { throw new ConfigurationException(String.format( "MTU greater than socket SO_SNDBUF, adjust %s to match MTU: mtuLength=%d, SO_SNDBUF=%d", SOCKET_SNDBUF_LENGTH_PROP_NAME, ctx.mtuLength(), soSndBuf)); } if (ctx.initialWindowLength() > maxSoRcvBuf) { throw new ConfigurationException("window length greater than socket SO_RCVBUF, increase '" + Configuration.INITIAL_WINDOW_LENGTH_PROP_NAME + "' to match window: windowLength=" + ctx.initialWindowLength() + ", SO_RCVBUF=" + maxSoRcvBuf); } } catch (final IOException ex) { throw new AeronException("probe socket: " + ex.toString(), ex); } }
Example 20
Source File: ShellUnit.java From UMS-Interface with GNU General Public License v3.0 | 4 votes |
/** * last exit code for root * */ // static public int exitValue; // /** // * execute the command through shell // * @param root should be execute as root // *@param cmd command // * */ // static private String execSU(String cmd,boolean root) // { // String outString = ""; // try { // char[] buff = new char[1024*30]; // Process process; // if(root) // process = Runtime.getRuntime().execSU("su"); // else // process = Runtime.getRuntime().execSU("sh"); // OutputStreamWriter stdinStream = new OutputStreamWriter(process.getOutputStream()); // InputStreamReader stdoutStream = new InputStreamReader(process.getInputStream()); // stdinStream.write(cmd+"\n"); // stdinStream.write("exit\n"); // stdinStream.flush(); // process.waitFor(); // int __count = stdoutStream.read(buff); // if(__count>0) // { // outString = new String(buff,0,__count); // } // //} // stdErr = null; // int count = new InputStreamReader(process.getErrorStream()).read(buff); // if(count > 0) // stdErr = new String(buff,0,count); // } catch (IOException e) { // // TODO 自动生成的 catch 块 // e.printStackTrace(); // stdErr = "by execSU:IOException,process.execSU fail"; // //return null; // return ""; // } catch (InterruptedException e) { // // TODO 自动生成的 catch 块 // e.printStackTrace(); // stdErr = "by execSU:InterruptedException,process.waitFor fail"; // //return null; // return ""; // } // return outString; // } static synchronized private String execSU(String cmd)//remember synchronized { char[] buff = new char[1024*30]; StringBuffer strBuff = new StringBuffer(); stdErr = null; if(!sSuReady) { stdErr = "su is not ready"; return ""; } String finishflag = "~~~ums_task_"+sTaskID+"_finished~~~"; sTaskID++; int flagLength = finishflag.length(); String task = cmd+"\necho "+finishflag+"\n";//remember '\n' try { int count ; // rawLog.logWrite("RIN",task); // Log.d("UMS_DEBUG","[ IN]>>"+task); sInStream.write(task); sInStream.flush(); while (true) { count = sOutStream.read(buff);//remember check ready,or block. if (count > 0) { strBuff.append(buff, 0, count); // rawLog.logWrite("ROUT",strBuff.toString()); // Log.d("UMS_DEBUG","[ OUT]>>"+strBuff.toString()); int searchBegin = strBuff.length() - count - flagLength; if(searchBegin<0) searchBegin = 0; if(strBuff.indexOf(finishflag,searchBegin)>=0) break; } } if(sErrStream.ready()) { count = sErrStream.read(buff); if (count > 0) { stdErr = new String(buff, 0, count); // rawLog.logWrite("RERR",stdErr); // Log.d("UMS_DEBUG","[ ERR]>>"+stdErr); } } strBuff.delete(strBuff.length()-flagLength-1,strBuff.length()); return strBuff.toString(); } catch (IOException e) { e.printStackTrace(); stdErr = "exec SU fail:"+e.toString(); return ""; } }