Java Examples for java.io.IOException
The following java examples will help you to understand the usage of java.io.IOException. These source code samples are taken from different open source projects.
Example 1
Project: ikvm-monotouch-master File: InputStreamWrapper.java View source code |
public int read() throws java.io.IOException { try { if (false) throw new cli.System.IO.IOException(); if (false) throw new cli.System.ObjectDisposedException(null); int i = stream.ReadByte(); if (i == -1) { atEOF = true; } return i; } catch (cli.System.IO.IOException x) { java.io.IOException ex = new java.io.IOException(); ex.initCause(x); throw ex; } catch (cli.System.ObjectDisposedException x) { java.io.IOException ex = new java.io.IOException(); ex.initCause(x); throw ex; } }
Example 2
Project: IKVM.NET-cvs-clone-master File: InputStreamWrapper.java View source code |
public int read() throws java.io.IOException { try { if (false) throw new cli.System.IO.IOException(); if (false) throw new cli.System.ObjectDisposedException(null); int i = stream.ReadByte(); if (i == -1) { atEOF = true; } return i; } catch (cli.System.IO.IOException x) { java.io.IOException ex = new java.io.IOException(); ex.initCause(x); throw ex; } catch (cli.System.ObjectDisposedException x) { java.io.IOException ex = new java.io.IOException(); ex.initCause(x); throw ex; } }
Example 3
Project: braintree_java-master File: HttpHelper.java View source code |
public static HttpURLConnection execute(String method, String urlS, String body) throws java.net.MalformedURLException, java.io.IOException, java.net.ProtocolException {
URL url = new URL(urlS);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod(method);
connection.addRequestProperty("X-ApiVersion", Configuration.apiVersion());
connection.addRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setDoOutput(true);
if (body != null) {
connection.getOutputStream().write(body.getBytes("UTF-8"));
connection.getOutputStream().close();
}
return connection;
}
Example 4
Project: elasticsearch-knapsack-master File: BZip2BitOutputStreamTests.java View source code |
// Boolean /** * Test writing 8 zeroes * @throws java.io.IOException */ @Test public void testBooleanFalse8() throws IOException { byte[] expected = { 0 }; ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); BZip2BitOutputStream outputStream = new BZip2BitOutputStream(byteArrayOutputStream); for (int i = 0; i < 8; i++) { outputStream.writeBoolean(false); } outputStream.flush(); assertArrayEquals(expected, byteArrayOutputStream.toByteArray()); }
Example 5
Project: rmiio-slf4j-master File: _RemoteFileServer_Stub.java View source code |
public void sendFile(RemoteInputStream arg0) throws java.rmi.RemoteException, java.io.IOException { if (!Util.isLocal(this)) { try { org.omg.CORBA_2_3.portable.InputStream in = null; try { OutputStream out = _request("sendFile", true); Util.writeRemoteObject(out, arg0); _invoke(out); } catch (ApplicationException ex) { in = (org.omg.CORBA_2_3.portable.InputStream) ex.getInputStream(); String $_id = in.read_string(); if ($_id.equals("IDL:java/io/IOEx:1.0")) { throw (java.io.IOException) in.read_value(java.io.IOException.class); } throw new UnexpectedException($_id); } catch (RemarshalException ex) { sendFile(arg0); } finally { _releaseReply(in); } } catch (SystemException ex) { throw Util.mapSystemException(ex); } } else { ServantObject so = _servant_preinvoke("sendFile", RemoteFileServer.class); if (so == null) { sendFile(arg0); return; } try { RemoteInputStream arg0Copy = (RemoteInputStream) Util.copyObject(arg0, _orb()); ((RemoteFileServer) so.servant).sendFile(arg0Copy); } catch (Throwable ex) { Throwable exCopy = (Throwable) Util.copyObject(ex, _orb()); if (exCopy instanceof java.io.IOException) { throw (java.io.IOException) exCopy; } throw Util.wrapException(exCopy); } finally { _servant_postinvoke(so); } } }
Example 6
Project: robonobo-master File: Formatter.java View source code |
/**
* @param map Optional XMLNS logic store used by this function
* to avoid duplication in output, managed by the caller to be
* specific to a scope. Forms a part of the whole XMLNS
* process.
* @param prefix QName prefix for namespace
* @param ns Namespace URI
* @param out Required target output
*/
protected void xmlns(gnu.iou.objmap map, String prefix, String ns, gnu.iou.dom.Formatter out) throws java.io.IOException {
if (null != ns && 0 < ns.length() && (null == map || null == map.get(prefix))) {
if (null == prefix || 1 > prefix.length())
prefix = PR_NIL;
if (null != map) {
if (null != map.get(prefix))
return;
else
map.put(prefix, ns);
}
out.print(' ');
if (PR_NIL != prefix) {
out.print("xmlns:");
out.print(prefix);
out.print('=');
} else
out.print("xmlns=");
//
out.printSafeQuoted(ns);
}
}
Example 7
Project: newspaper-batch-event-framework-master File: Utils.java View source code |
/** * Utility method to read an inputstream to a hadoop text * * @param inputStream * * @return * @throws java.io.IOException */ public static Text asText(InputStream inputStream) throws IOException { StringBuilder builder = new StringBuilder(); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String line; while ((line = reader.readLine()) != null) { builder.append(line); } reader.close(); return new Text(builder.toString()); }
Example 8
Project: PM-master File: ResourceLoader.java View source code |
public InputStream getResourceStream(String path) throws java.io.IOException { ClassLoader cl = this.getClass().getClassLoader(); if (cl == null) { cl = ClassLoader.getSystemClassLoader(); } InputStream stream = cl.getResourceAsStream(path); if (stream == null) { throw new java.io.IOException("Resource not found: " + path); } return stream; }
Example 9
Project: pmd-master File: ResourceLoader.java View source code |
public InputStream getResourceStream(String path) throws java.io.IOException { ClassLoader cl = this.getClass().getClassLoader(); if (cl == null) { cl = ClassLoader.getSystemClassLoader(); } InputStream stream = cl.getResourceAsStream(path); if (stream == null) { throw new java.io.IOException("Resource not found: " + path); } return stream; }
Example 10
Project: TimeSeriesClassification-master File: BinaryFile.java View source code |
/** * Reads a 16-bit word. Can be signed or unsigned depending on the signed property. Can be little or big endian depending on the endian property. * * @return A word stored in an int. * @exception java.io.IOException If an IO exception occurs. */ public int readWord() throws java.io.IOException { short a, b; int result; a = readUnsignedByte(); b = readUnsignedByte(); if (_endian == BIG_ENDIAN) result = ((a << 8) | b); else result = (a | (b << 8)); if (_signed) if ((result & 0x8000) == 0x8000) result = -(0x10000 - result); return result; }
Example 11
Project: X.Ray-master File: StreamUtility.java View source code |
/** * @param is * 读�转�inputstream�数� * @return String 转�结果 * @throws java.io.IOException */ public static String readFromStream(InputStream is) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int len = 0; while ((len = is.read(buffer)) != -1) { baos.write(buffer, 0, len); } is.close(); String result = baos.toString(); baos.close(); return result; }
Example 12
Project: musique-master File: WavWriter.java View source code |
public static void wavwriter_writeheaders(java.io.FileOutputStream f, int datasize, int numchannels, int samplerate, int bytespersample, int bitspersample) { byte[] buffAsBytes = new byte[4]; /* write RIFF header */ buffAsBytes[0] = 82; buffAsBytes[1] = 73; buffAsBytes[2] = 70; // "RIFF" ascii values buffAsBytes[3] = 70; try { f.write(buffAsBytes, 0, 4); } catch (java.io.IOException ioe) { } write_uint32(f, (36 + datasize)); buffAsBytes[0] = 87; buffAsBytes[1] = 65; buffAsBytes[2] = 86; // "WAVE" ascii values buffAsBytes[3] = 69; try { f.write(buffAsBytes, 0, 4); } catch (java.io.IOException ioe) { } /* write fmt header */ buffAsBytes[0] = 102; buffAsBytes[1] = 109; buffAsBytes[2] = 116; // "fmt " ascii values buffAsBytes[3] = 32; try { f.write(buffAsBytes, 0, 4); } catch (java.io.IOException ioe) { } write_uint32(f, 16); // PCM data write_uint16(f, 1); write_uint16(f, numchannels); write_uint32(f, samplerate); // byterate write_uint32(f, (samplerate * numchannels * bytespersample)); write_uint16(f, (numchannels * bytespersample)); write_uint16(f, bitspersample); /* write data header */ buffAsBytes[0] = 100; buffAsBytes[1] = 97; buffAsBytes[2] = 116; // "data" ascii values buffAsBytes[3] = 97; try { f.write(buffAsBytes, 0, 4); } catch (java.io.IOException ioe) { } write_uint32(f, datasize); }
Example 13
Project: pluotsorbet-master File: constructor.java View source code |
/** * Runs the test using the specified harness. * * @param harness the test harness (<code>null</code> not permitted). */ public void test(TestHarness harness) { IOException object1 = new IOException("nothing happens"); harness.check(object1 != null); harness.check(object1.toString(), "java.io.IOException: nothing happens"); IOException object2 = new IOException((String) null); harness.check(object2 != null); harness.check(object2.toString(), "java.io.IOException"); }
Example 14
Project: TorProxy-master File: TorSocketImpl.java View source code |
protected void connect(SocketAddress address, int timeout) throws java.io.IOException { try { if (address.getClass().equals(Class.forName("java.net.InetSocketAddress")) == false) { throw new java.io.IOException(); } } catch (ClassNotFoundException e) { throw new java.io.IOException(); } InetSocketAddress inetSockAdr = (InetSocketAddress) address; this.connect(inetSockAdr.getAddress(), inetSockAdr.getPort()); }
Example 15
Project: razberry-java-client-library-master File: RestHelper.java View source code |
public static String postJsonData(Reference reference, String jsonData, Iterable<Parameter> extraParameters) throws java.io.IOException {
reference.addQueryParameters(extraParameters);
ClientResource cr = new ClientResource(reference);
cr.setMethod(Method.POST);
Representation rep = cr.post(new JsonRepresentation(jsonData));
Response resp = cr.getResponse();
String jsonResponse = "";
String nid = "";
if (resp.getStatus().isSuccess()) {
jsonResponse = resp.getEntity().getText();
return jsonResponse;
} else {
System.out.println(resp.getStatus().getName());
}
return "";
}
Example 16
Project: platypus-master File: ProtoReader.java View source code |
/** * Gets the next tag from the input stream. * * @return the next available tag. * @throws java.io.IOException if an I/O error occurs. */ public int getNextTag() throws java.io.IOException { if (isTagReady) { skip(); } isTagReady = true; int tag; try { tag = stream.readUnsignedByte(); } catch (java.io.EOFException ex) { currentTag = CoreTags.TAG_EOF; currentSize = 0; return currentTag; } currentSize = stream.readInt(); currentTag = tag; return currentTag; }
Example 17
Project: presto-riak-master File: DirectConnection.java View source code |
public void ping() throws java.io.IOException, OtpAuthException, OtpErlangExit {
// connection test
OtpErlangObject received = call("erlang", "date", new OtpErlangList());
System.out.println(received);
OtpErlangTuple ok_or_error = (OtpErlangTuple) call("riak", "local_client", new OtpErlangList());
this.local_client = ok_or_error.elementAt(1);
System.out.println(this.local_client);
}
Example 18
Project: pentaho-hadoop-shims-master File: RunningJobProxyV2.java View source code |
/** * Get a list of events indicating success/failure of underlying tasks. * * @param startIndex offset/index to start fetching events from * @return an array of events * @throws java.io.IOException */ @Override public org.pentaho.hadoop.shim.api.mapred.TaskCompletionEvent[] getTaskCompletionEvents(int startIndex) throws IOException { org.apache.hadoop.mapred.TaskCompletionEvent[] events = delegateJob.getTaskCompletionEvents(startIndex); org.pentaho.hadoop.shim.api.mapred.TaskCompletionEvent[] wrapped = new org.pentaho.hadoop.shim.api.mapred.TaskCompletionEvent[events.length]; for (int i = 0; i < wrapped.length; i++) { wrapped[i] = new TaskCompletionEventProxy(events[i]); } return wrapped; }
Example 19
Project: AIWekaProject-master File: scanner.java View source code |
/* recognize and return the next complete token */
public Symbol next_token() throws java.io.IOException {
// set stuff up first time we are called.
if (next_char == -2)
init();
for (; ; ) switch(next_char) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
/* parse a decimal integer */
int i_val = 0;
do {
i_val = i_val * 10 + (next_char - '0');
advance();
} while (next_char >= '0' && next_char <= '9');
return new Symbol(sym.NUMBER, new Integer(i_val));
case ';':
advance();
return new Symbol(sym.SEMI);
case '+':
advance();
return new Symbol(sym.PLUS);
case '-':
advance();
return new Symbol(sym.MINUS);
case '*':
advance();
return new Symbol(sym.TIMES);
case '/':
advance();
return new Symbol(sym.DIVIDE);
case '%':
advance();
return new Symbol(sym.MOD);
case '(':
advance();
return new Symbol(sym.LPAREN);
case ')':
advance();
return new Symbol(sym.RPAREN);
case -1:
return new Symbol(sym.EOF);
default:
/* in this simple scanner we just ignore everything else */
advance();
break;
}
}
Example 20
Project: Java-CUP-jLex-Example-master File: scanner.java View source code |
/* recognize and return the next complete token */
public Symbol next_token() throws java.io.IOException {
// set stuff up first time we are called.
if (next_char == -2)
init();
for (; ; ) switch(next_char) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
/* parse a decimal integer */
int i_val = 0;
do {
i_val = i_val * 10 + (next_char - '0');
advance();
} while (next_char >= '0' && next_char <= '9');
return new Symbol(sym.NUMBER, new Integer(i_val));
case ';':
advance();
return new Symbol(sym.SEMI);
case '+':
advance();
return new Symbol(sym.PLUS);
case '-':
advance();
return new Symbol(sym.MINUS);
case '*':
advance();
return new Symbol(sym.TIMES);
case '/':
advance();
return new Symbol(sym.DIVIDE);
case '%':
advance();
return new Symbol(sym.MOD);
case '(':
advance();
return new Symbol(sym.LPAREN);
case ')':
advance();
return new Symbol(sym.RPAREN);
case -1:
return new Symbol(sym.EOF);
default:
/* in this simple scanner we just ignore everything else */
advance();
break;
}
}
Example 21
Project: MoleculeViewer-master File: scanner.java View source code |
/* recognize and return the next complete token */
public Symbol next_token() throws java.io.IOException {
for (; ; ) switch(next_char) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
/* parse a decimal integer */
int i_val = 0;
do {
i_val = i_val * 10 + (next_char - '0');
advance();
} while (next_char >= '0' && next_char <= '9');
return new Symbol(sym.NUMBER, new Integer(i_val));
case ';':
advance();
return new Symbol(sym.SEMI);
case '+':
advance();
return new Symbol(sym.PLUS);
case '-':
advance();
return new Symbol(sym.MINUS);
case '*':
advance();
return new Symbol(sym.TIMES);
case '/':
advance();
return new Symbol(sym.DIVIDE);
case '%':
advance();
return new Symbol(sym.MOD);
case '(':
advance();
return new Symbol(sym.LPAREN);
case ')':
advance();
return new Symbol(sym.RPAREN);
case -1:
return new Symbol(sym.EOF);
default:
/* in this simple scanner we just ignore everything else */
advance();
break;
}
}
Example 22
Project: postgrado-master File: scanner.java View source code |
/* recognize and return the next complete token */
public Symbol next_token() throws java.io.IOException {
// set stuff up first time we are called.
if (next_char == -2)
init();
for (; ; ) switch(next_char) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
/* parse a decimal integer */
int i_val = 0;
do {
i_val = i_val * 10 + (next_char - '0');
advance();
} while (next_char >= '0' && next_char <= '9');
return new Symbol(sym.NUMBER, new Integer(i_val));
case ';':
advance();
return new Symbol(sym.SEMI);
case '+':
advance();
return new Symbol(sym.PLUS);
case '-':
advance();
return new Symbol(sym.MINUS);
case '*':
advance();
return new Symbol(sym.TIMES);
case '/':
advance();
return new Symbol(sym.DIVIDE);
case '%':
advance();
return new Symbol(sym.MOD);
case '(':
advance();
return new Symbol(sym.LPAREN);
case ')':
advance();
return new Symbol(sym.RPAREN);
case -1:
return new Symbol(sym.EOF);
default:
/* in this simple scanner we just ignore everything else */
advance();
break;
}
}
Example 23
Project: zinara-master File: scanner.java View source code |
/* recognize and return the next complete token */
public Symbol next_token() throws java.io.IOException {
// set stuff up first time we are called.
if (next_char == -2)
init();
for (; ; ) switch(next_char) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
/* parse a decimal integer */
int i_val = 0;
do {
i_val = i_val * 10 + (next_char - '0');
advance();
} while (next_char >= '0' && next_char <= '9');
return new Symbol(sym.NUMBER, new Integer(i_val));
case ';':
advance();
return new Symbol(sym.SEMI);
case '+':
advance();
return new Symbol(sym.PLUS);
case '-':
advance();
return new Symbol(sym.MINUS);
case '*':
advance();
return new Symbol(sym.TIMES);
case '/':
advance();
return new Symbol(sym.DIVIDE);
case '%':
advance();
return new Symbol(sym.MOD);
case '(':
advance();
return new Symbol(sym.LPAREN);
case ')':
advance();
return new Symbol(sym.RPAREN);
case -1:
return new Symbol(sym.EOF);
default:
/* in this simple scanner we just ignore everything else */
advance();
break;
}
}
Example 24
Project: dbeaver-master File: XMLBuilder.java View source code |
private void init(java.io.Writer writer, String documentEncoding, boolean printHeader) throws java.io.IOException {
this.writer = new java.io.BufferedWriter(writer, IO_BUFFER_SIZE);
if (printHeader) {
if (documentEncoding != null) {
this.writer.write(XMLConstants.XML_HEADER(documentEncoding));
} else {
this.writer.write(XMLConstants.XML_HEADER());
}
}
}
Example 25
Project: haskell-java-parser-master File: Trychk3.java View source code |
public static void main(String args[]) {
int i, j, sum, value;
j = 0;
sum = 0;
value = 5;
for (i = 0; i < 5; i++) {
try {
j = j + 1;
j = other(j);
if (j > 6)
break;
sum = sum + i;
} catch (java.io.IOException e) {
j = j * 2;
sum = sum + value;
if (i > 1) {
break;
}
}
}
if (value != 5)
j = j + 1;
System.out.println(j + sum);
System.exit(j + sum);
}
Example 26
Project: jelectrum-master File: BitcoinRPC.java View source code |
protected String sendPost(String url, String postdata) throws java.io.IOException {
URL u = new URL(url);
HttpURLConnection connection = (HttpURLConnection) u.openConnection();
String basic = username + ":" + password;
String encoded = Base64.encodeBase64String(basic.getBytes());
connection.setRequestProperty("Authorization", "Basic " + encoded);
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setInstanceFollowRedirects(false);
connection.setRequestMethod("POST");
connection.setRequestProperty("charset", "utf-8");
connection.setRequestProperty("Content-Length", "" + Integer.toString(postdata.getBytes().length));
connection.setUseCaches(false);
OutputStream wr = connection.getOutputStream();
wr.write(postdata.getBytes());
wr.flush();
wr.close();
Scanner scan;
if (connection.getResponseCode() != 500) {
scan = new Scanner(connection.getInputStream());
} else {
scan = new Scanner(connection.getErrorStream());
}
StringBuilder sb = new StringBuilder();
while (scan.hasNextLine()) {
String line = scan.nextLine();
sb.append(line);
sb.append('\n');
}
scan.close();
connection.disconnect();
return sb.toString();
}
Example 27
Project: Kademlia-master File: ConnectReceiver.java View source code |
/** * Handle receiving a ConnectMessage * * @param comm * * @throws java.io.IOException */ @Override public void receive(Message incoming, int comm) throws IOException { ConnectMessage mess = (ConnectMessage) incoming; /* Update the local space by inserting the origin node. */ this.localNode.getRoutingTable().insert(mess.getOrigin()); /* Respond to the connect request */ AcknowledgeMessage msg = new AcknowledgeMessage(this.localNode.getNode()); /* Reply to the connect message with an Acknowledgement */ this.server.reply(mess.getOrigin(), msg, comm); }
Example 28
Project: reunion-master File: Handler.java View source code |
protected java.net.URLConnection openConnection(java.net.URL url) throws java.io.IOException { return new URLConnection(url) { private java.net.Socket socket; @Override public void connect() throws IOException { URL url = getURL(); socket = new Socket(url.getHost(), url.getPort() == -1 ? url.getDefaultPort() : url.getPort()); connected = true; } public java.io.InputStream getInputStream() throws java.io.IOException { if (!connected) connect(); return socket.getInputStream(); } }; }
Example 29
Project: SocialKademlia-master File: ConnectReceiver.java View source code |
/** * Handle receiving a ConnectMessage * * @param comm * * @throws java.io.IOException */ @Override public void receive(Message incoming, int comm) throws IOException { ConnectMessage mess = (ConnectMessage) incoming; /* Update the local space by inserting the origin node. */ this.localNode.getRoutingTable().insert(mess.getOrigin()); /* Respond to the connect request */ AcknowledgeMessage msg = new AcknowledgeMessage(this.localNode.getNode()); /* Reply to the connect message with an Acknowledgement */ this.server.reply(mess.getOrigin(), msg, comm); }
Example 30
Project: StarMod-master File: ByteBufUtils.java View source code |
/** * Writes an UTF8 string to a byte buffer. * * @param buf The byte buffer to write too * @param value The string to write * @throws java.io.IOException If the writing fails */ public static void writeUTF8(ByteBuf buf, String value) throws IOException { final byte[] bytes = value.getBytes(StandardCharsets.UTF_8); if (bytes.length >= Short.MAX_VALUE) { throw new IOException("Attempt to write a string with a length greater than Short.MAX_VALUE to ByteBuf!"); } buf.writeShort(value.length()); buf.writeBytes(bytes); }
Example 31
Project: Custom-Salem-master File: LoggingOutputStream.java View source code |
/*\* \* upon flush() write the existing contents of the OutputStream \* to the logger as a log record. \* @throws java.io.IOException in case of error \*/ public void flush() throws IOException { String record; synchronized (this) { super.flush(); record = this.toString(); super.reset(); if (record.length() == 0 || record.equals(lineSeparator)) { // avoid empty records return; } logger.logp(level, "", "", record); } }
Example 32
Project: h2gis-master File: ReadBufferManager.java View source code |
/** * Moves the window if necessary to contain the desired byte and returns the * position of the byte in the window * * @param bytePos * @throws java.io.IOException */ private int getWindowOffset(long bytePos, int length) throws IOException { long desiredMin = bytePos; long desiredMax = desiredMin + length - 1; if ((desiredMin >= windowStart) && (desiredMax < windowStart + buffer.capacity())) { long res = desiredMin - windowStart; if (res < Integer.MAX_VALUE) { return (int) res; } else { throw new IOException("This buffer is quite large..."); } } else { long bufferCapacity = Math.max(bufferSize, length); long size = channel.size(); bufferCapacity = Math.min(bufferCapacity, size - bytePos); if (bufferCapacity > Integer.MAX_VALUE) { throw new IOException("Woaw ! You want to have a REALLY LARGE buffer !"); } windowStart = bytePos; channel.position(windowStart); if (buffer.capacity() != bufferCapacity) { ByteOrder order = buffer.order(); buffer = ByteBuffer.allocate((int) bufferCapacity); buffer.order(order); } else { buffer.clear(); } channel.read(buffer); buffer.flip(); return (int) (desiredMin - windowStart); } }
Example 33
Project: iterator-master File: User.java View source code |
public static void encode_(com.jsoniter.demo.User obj, com.jsoniter.output.JsonStream stream) throws java.io.IOException {
com.jsoniter.output.CodegenAccess.writeStringWithoutQuote((java.lang.String) obj.lastName, stream);
stream.writeRaw("\",\"firstName\":\"", 15);
com.jsoniter.output.CodegenAccess.writeStringWithoutQuote((java.lang.String) obj.firstName, stream);
stream.writeRaw("\",\"score\":", 10);
stream.writeVal((int) obj.score);
}
Example 34
Project: josm-plugins-master File: FolderOutStream.java View source code |
int OpenFile() throws java.io.IOException {
int askMode;
if (_extractStatuses.get(_currentIndex))
askMode = _testMode ? IInArchive.NExtract_NAskMode_kTest : IInArchive.NExtract_NAskMode_kExtract;
else
askMode = IInArchive.NExtract_NAskMode_kSkip;
int index = _startIndex + _currentIndex;
// RINOK(_extractCallback->GetStream(_ref2Offset + index, &realOutStream, askMode));
// TBD
java.io.OutputStream[] realOutStream2 = new java.io.OutputStream[1];
int ret = _extractCallback.GetStream(_ref2Offset + index, realOutStream2, askMode);
if (ret != HRESULT.S_OK)
return ret;
java.io.OutputStream realOutStream = realOutStream2[0];
_outStreamWithHashSpec.SetStream(realOutStream);
_outStreamWithHashSpec.Init();
if (askMode == IInArchive.NExtract_NAskMode_kExtract && (realOutStream == null)) {
FileItem fileInfo = _archiveDatabase.Files.get(index);
if (!fileInfo.IsAnti && !fileInfo.IsDirectory)
askMode = IInArchive.NExtract_NAskMode_kSkip;
}
return _extractCallback.PrepareOperation(askMode);
}
Example 35
Project: lombok-pg-master File: CleanupQuietly.java View source code |
void test1(BufferedReader reader) throws Exception {
try {
for (String next = reader.readLine(); next != null; next = reader.readLine()) System.out.println(next);
} finally {
if (reader instanceof java.io.Closeable) {
try {
((java.io.Closeable) reader).close();
} catch (final java.io.IOException $ex) {
}
}
}
}
Example 36
Project: muCommander-master File: FolderOutStream.java View source code |
int OpenFile() throws java.io.IOException {
int askMode;
if (_extractStatuses.get(_currentIndex))
askMode = _testMode ? IInArchive.NExtract_NAskMode_kTest : IInArchive.NExtract_NAskMode_kExtract;
else
askMode = IInArchive.NExtract_NAskMode_kSkip;
int index = _startIndex + _currentIndex;
// RINOK(_extractCallback->GetStream(_ref2Offset + index, &realOutStream, askMode));
// TBD
java.io.OutputStream[] realOutStream2 = new java.io.OutputStream[1];
int ret = _extractCallback.GetStream(_ref2Offset + index, realOutStream2, askMode);
if (ret != HRESULT.S_OK)
return ret;
java.io.OutputStream realOutStream = realOutStream2[0];
_outStreamWithHashSpec.SetStream(realOutStream);
_outStreamWithHashSpec.Init();
if (askMode == IInArchive.NExtract_NAskMode_kExtract && (realOutStream == null)) {
FileItem fileInfo = _archiveDatabase.Files.get(index);
if (!fileInfo.IsAnti && !fileInfo.IsDirectory)
askMode = IInArchive.NExtract_NAskMode_kSkip;
}
return _extractCallback.PrepareOperation(askMode);
}
Example 37
Project: rrd4j-master File: Test.java View source code |
/** * <p>main.</p> * * @param args an array of {@link java.lang.String} objects. * @throws java.io.IOException if any. */ public static void main(String[] args) throws IOException { BufferedReader r = new BufferedReader(new FileReader(LOADAVG_FILE)); try { String line = r.readLine(); if (line != null) { String[] loads = line.split("\\s+"); if (loads.length >= 3) { String load = loads[0] + " " + loads[1] + " " + loads[2]; System.out.println("LOAD = " + load); return; } System.out.println("Unexpected error while parsing file " + LOADAVG_FILE); } } finally { r.close(); } }
Example 38
Project: XACML-Policy-Analysis-Tool-master File: Utils.java View source code |
public static String readFileAsString(File file) throws java.io.IOException {
StringBuffer fileData = new StringBuffer(1000);
BufferedReader reader = new BufferedReader(new FileReader(file));
char[] buf = new char[1024];
int numRead = 0;
while ((numRead = reader.read(buf)) != -1) {
String readData = String.valueOf(buf, 0, numRead);
fileData.append(readData);
buf = new char[1024];
}
reader.close();
return fileData.toString();
}
Example 39
Project: XhsEmoticonsKeyboard-master File: ImageLoader.java View source code |
/** * @param uriStr * @param imageView * @throws java.io.IOException */ @Override public void displayImage(String uriStr, ImageView imageView) throws IOException { switch(Scheme.ofUri(uriStr)) { case FILE: displayImageFromFile(uriStr, imageView); return; case ASSETS: displayImageFromAssets(uriStr, imageView); return; case DRAWABLE: displayImageFromDrawable(uriStr, imageView); return; case HTTP: case HTTPS: displayImageFromNetwork(uriStr, imageView); return; case CONTENT: displayImageFromContent(uriStr, imageView); return; case UNKNOWN: default: Matcher m = NUMBER_PATTERN.matcher(uriStr); if (m.matches()) { displayImageFromResource(Integer.parseInt(uriStr), imageView); return; } displayImageFromOtherSource(uriStr, imageView); return; } }
Example 40
Project: intellij-community-master File: ExceptionCheckingTest.java View source code |
public void testCheckedUnhandledException() throws Exception {
PsiMethodCallExpression methodCall = createCall("void foo() { throwsIOException(); }");
List<PsiClassType> exceptions = ExceptionUtil.getUnhandledExceptions(methodCall, null);
assertEquals(1, exceptions.size());
assertEquals("java.io.IOException", exceptions.get(0).getCanonicalText());
}
Example 41
Project: seal-master File: TestHashSetVariantTable.java View source code |
@Test
public void testMultiple() throws java.io.IOException {
String data = "585 1 14435 14436 rs1045951 0 - G G C/T genomic single unknown 0 0 unknown exact 3\n" + "585 1 10259 10260 rs72477211 0 + C C A/G genomic single unknown 0 0 unknown exact 1";
loadIntoEmptyTable(data);
assertTrue(emptyTable.isVariantLocation("1", 14435));
assertTrue(emptyTable.isVariantLocation("1", 10259));
}
Example 42
Project: jakstab-master File: BinaryInputBuffer.java View source code |
/** * Reads an unsigned 4-byte integer from the file and returns it the lower 4 bytes of a long. * Advances the file pointer by 4. */ public long readDWORD() throws java.io.IOException { if (current + 3 >= getSize()) throw new java.io.IOException("BinaryInputBuffer.readDWORD: Premature EOF"); int b1 = readBYTE(); int b2 = readBYTE(); int b3 = readBYTE(); int b4 = readBYTE(); long result = ((b1 & 0xFFL) | ((b2 & 0xFFL) << 8) | ((b3 & 0xFFL) << 16) | ((b4 & 0xFFL) << 24)); return result; }
Example 43
Project: opennlp-master File: AbstractModelReader.java View source code |
protected int[][] getOutcomePatterns() throws java.io.IOException {
int numOCTypes = readInt();
int[][] outcomePatterns = new int[numOCTypes][];
for (int i = 0; i < numOCTypes; i++) {
StringTokenizer tok = new StringTokenizer(readUTF(), " ");
int[] infoInts = new int[tok.countTokens()];
for (int j = 0; tok.hasMoreTokens(); j++) {
infoInts[j] = Integer.parseInt(tok.nextToken());
}
outcomePatterns[i] = infoInts;
}
return outcomePatterns;
}
Example 44
Project: OpenNLP-Maxent-Joliciel-master File: AbstractModelReader.java View source code |
protected int[][] getOutcomePatterns() throws java.io.IOException {
int numOCTypes = readInt();
int[][] outcomePatterns = new int[numOCTypes][];
for (int i = 0; i < numOCTypes; i++) {
StringTokenizer tok = new StringTokenizer(readUTF(), " ");
int[] infoInts = new int[tok.countTokens()];
for (int j = 0; tok.hasMoreTokens(); j++) {
infoInts[j] = Integer.parseInt(tok.nextToken());
}
outcomePatterns[i] = infoInts;
}
return outcomePatterns;
}
Example 45
Project: swoop-master File: RacerClient.java View source code |
/** This method refers to the RACER alc-concept-coherent function * @return boolean true if the concept is coherent and false otherwise. * @param c java.lang.String The concept term. * @param logic int The logic to be used. It can be RacerConstants.K_LOGIC, RacerConstants.K4_LOGIC, or RacerConstants.S4_LOGIC * @exception java.io.IOException Thrown when there is a communication problem with the RACER server. * @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message. */ public boolean alcConceptCoherent(String c, int logic) throws java.io.IOException, RacerException { if (termParser != null) termParser.parseConcept(c); String res = send("(alc-concept-coherent '" + c + " :logic " + (logic == RacerConstants.K_LOGIC ? ":K)" : "") + (logic == RacerConstants.K4_LOGIC ? ":K4)" : "") + (logic == RacerConstants.S4_LOGIC ? ":S4)" : ""), true); return parseBoolean(res); }
Example 46
Project: AcademicTorrents-Downloader-master File: BEROutputStream.java View source code |
public void writeObject(Object obj) throws IOException { if (obj == null) { writeNull(); } else if (obj instanceof DERObject) { ((DERObject) obj).encode(this); } else if (obj instanceof DEREncodable) { ((DEREncodable) obj).getDERObject().encode(this); } else { throw new IOException("object not BEREncodable"); } }
Example 47
Project: ache-master File: CrawlerCommons.java View source code |
public static String getVersion() {
String path = "/version.prop";
InputStream stream = CrawlerCommons.class.getResourceAsStream(path);
if (stream == null) {
return "Unknown Version";
}
Properties props = new Properties();
try {
props.load(stream);
stream.close();
return (String) props.get("version");
} catch (IOException e) {
return "Unknown Version";
}
}
Example 48
Project: airball-for-android-master File: NonBlockingLineReader.java View source code |
public String maybeReadLine() throws IOException {
while (mInputStream.available() != 0) {
char c = (char) mInputStream.read();
if (c == '\n') {
String s = mStringBuilder.toString();
mStringBuilder = new StringBuilder();
return s;
} else {
mStringBuilder.append(c);
}
}
return null;
}
Example 49
Project: alien4cloud-master File: ImageResizeUtilTest.java View source code |
@Test
public void testComputeDimensions() throws IOException {
int[] results = ImageResizeUtil.computeDimensions(64, 64, 500, 250);
Assert.assertEquals(64, results[0]);
Assert.assertEquals(32, results[1]);
results = ImageResizeUtil.computeDimensions(64, 64, 250, 500);
Assert.assertEquals(32, results[0]);
Assert.assertEquals(64, results[1]);
}
Example 50
Project: Android-Backup-master File: TestHelper.java View source code |
public static String getResource(String name) throws IOException {
final InputStream resourceAsStream = TestHelper.class.getResourceAsStream(name);
assert (resourceAsStream != null);
int n;
byte[] buffer = new byte[8192];
ByteArrayOutputStream bos = new ByteArrayOutputStream();
while ((n = resourceAsStream.read(buffer)) != -1) {
bos.write(buffer, 0, n);
}
return new String(bos.toByteArray());
}
Example 51
Project: android-runtime-master File: Main.java View source code |
public static void main(String[] args) throws IOException {
if (args.length < 3) {
throw new IllegalArgumentException("Expects at least three arguments");
}
String inputBindingFilename = args[0];
String outputDir = args[1];
String[] libs = Arrays.copyOfRange(args, 2, args.length);
new Generator(outputDir, libs).writeBindings(inputBindingFilename);
}
Example 52
Project: Android-Templates-And-Utilities-master File: Parser.java View source code |
protected static void handleUnknownParameter(JsonParser parser) throws IOException, JsonParseException {
if (parser.getCurrentToken() == JsonToken.START_OBJECT)
while (parser.nextToken() != JsonToken.END_OBJECT) {
handleUnknownParameter(parser);
}
if (parser.getCurrentToken() == JsonToken.START_ARRAY)
while (parser.nextToken() != JsonToken.END_ARRAY) {
handleUnknownParameter(parser);
}
}
Example 53
Project: AndroidNetworkBench-master File: Streams.java View source code |
static String readFully(Reader reader) throws IOException {
try {
StringWriter writer = new StringWriter();
char[] buffer = new char[1024];
int count;
while ((count = reader.read(buffer)) != -1) {
writer.write(buffer, 0, count);
}
return writer.toString();
} finally {
reader.close();
}
}
Example 54
Project: androidPublish-master File: Strings.java View source code |
public static String fromStream(InputStream inputStream) throws IOException {
int numberBytesRead = 0;
StringBuilder out = new StringBuilder();
byte[] bytes = new byte[4096];
while (numberBytesRead != -1) {
out.append(new String(bytes, 0, numberBytesRead));
numberBytesRead = inputStream.read(bytes);
}
inputStream.close();
return out.toString();
}
Example 55
Project: AndroidSamples-master File: AppUtils.java View source code |
/** * Close outputStream * * @param is */ public static void closeStream(Closeable stream) { if (stream != null) { try { stream.close(); stream = null; } catch (IOException e) { } finally { if (stream != null) { try { stream.close(); } catch (IOException e) { stream = null; } stream = null; } } } }
Example 56
Project: android_libcore-master File: BEROutputStream.java View source code |
public void writeObject(Object obj) throws IOException { if (obj == null) { writeNull(); } else if (obj instanceof DERObject) { ((DERObject) obj).encode(this); } else if (obj instanceof DEREncodable) { ((DEREncodable) obj).getDERObject().encode(this); } else { throw new IOException("object not BEREncodable"); } }
Example 57
Project: AnimeBTDownloader-master File: Main.java View source code |
public static void main(String[] args) throws IOException {
Config.readConfig();
AnimeList.loadAnimeListFromFile();
MissionList.readList();
VideosList.loadVideosList();
UIform GUI = new UIform();
Dimension screensizeDimension = Toolkit.getDefaultToolkit().getScreenSize();
Dimension size = GUI.getSize();
int w = (int) (screensizeDimension.getWidth() / 2 - size.getWidth() / 2);
int h = (int) (screensizeDimension.getHeight() / 2 - size.getHeight() / 2);
GUI.setLocation(w, h);
}
Example 58
Project: ant-master File: ErrorHandler.java View source code |
public static ErrorResponse handleThrowable(Throwable throwable) {
if (throwable instanceof RetrofitException) {
RetrofitException retrofitException = (RetrofitException) throwable;
try {
return retrofitException.getErrorBodyAs(ErrorResponse.class);
} catch (IOException e) {
e.printStackTrace();
return new ErrorResponse(500, e.getLocalizedMessage());
}
}
return null;
}
Example 59
Project: ares-studio-master File: Test.java View source code |
public static void main(String[] args) {
ActionInfo ai = new ActionInfo();
// ai.properties.get("id").equals(obj)
// ai.other = "other";
File file = new File("ttt.test");
try {
file.createNewFile();
FileOutputStream fos = new FileOutputStream(file);
//XStreamConverter.getInstance().write(fos, ai);
} catch (IOException e) {
e.printStackTrace();
}
}
Example 60
Project: asr-tsp-master File: Recepteur.java View source code |
public void run() {
while (true) {
while (mess.readMessage(sc) != ReadMessageStatus.ReadDataCompleted) ;
String s = null;
try {
s = (String) mess.getData();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(s);
}
}
Example 61
Project: atlas-lb-master File: BEROutputStream.java View source code |
public void writeObject(Object obj) throws IOException { if (obj == null) { writeNull(); } else if (obj instanceof DERObject) { ((DERObject) obj).encode(this); } else if (obj instanceof DEREncodable) { ((DEREncodable) obj).getDERObject().encode(this); } else { throw new IOException("object not BEREncodable"); } }
Example 62
Project: auto-matter-master File: SimpleExample.java View source code |
public static void main(final String... args) throws IOException {
Foobar foobar = new FoobarBuilder().foo("hello world").bar(17).build();
out.println("bar: " + foobar.bar());
out.println("foo: " + foobar.foo());
out.println("foobar: " + foobar);
Foobar modified = foobar.builder().bar(18).build();
out.println("modified: " + modified);
}
Example 63
Project: bboss-master File: TestIocPlugin.java View source code |
@Test
public void testiocplugin() throws IOException {
BaseApplicationContext excelMapping = DefaultApplicationContext.getApplicationContext("org/frameworkset/spi/assemble/plugin/excelFieldInfo.xml");
POIExcelService serice = excelMapping.getTBeanObject("POIExcelService", POIExcelService.class);
serice.parseHSSFMapList(null, null, "exceltemplatefile1");
}
Example 64
Project: bbs.newgxu.cn-master File: JsonUtil.java View source code |
public static void sendJsonStr(String json) {
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("application/json;charset=utf-8");
try {
PrintWriter writer = response.getWriter();
writer.write(json);
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Example 65
Project: Beneath-master File: FileUtils.java View source code |
public static String loadAsString(String file) {
String result = "";
try {
BufferedReader reader = new BufferedReader(new FileReader(file));
String buffer = "";
while ((buffer = reader.readLine()) != null) {
result += buffer + "\n";
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
Example 66
Project: betsy-master File: GitUtil.java View source code |
public static String getGitCommit() {
Runtime rt = Runtime.getRuntime();
try {
Process pr = rt.exec("git rev-parse HEAD");
try (BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()))) {
String line = input.readLine();
if (line.startsWith("fatal:")) {
//no commit hash
return "";
} else {
return line;
}
}
} catch (IOException e) {
return "";
}
}
Example 67
Project: bitcoin-android-master File: BEROutputStream.java View source code |
public void writeObject(Object obj) throws IOException { if (obj == null) { writeNull(); } else if (obj instanceof DERObject) { ((DERObject) obj).encode(this); } else if (obj instanceof DEREncodable) { ((DEREncodable) obj).getDERObject().encode(this); } else { throw new IOException("object not BEREncodable"); } }
Example 68
Project: bitcoin-mobile-android-master File: BEROutputStream.java View source code |
public void writeObject(Object obj) throws IOException { if (obj == null) { writeNull(); } else if (obj instanceof DERObject) { ((DERObject) obj).encode(this); } else if (obj instanceof DEREncodable) { ((DEREncodable) obj).getDERObject().encode(this); } else { throw new IOException("object not BEREncodable"); } }
Example 69
Project: BitMate-master File: BEROutputStream.java View source code |
public void writeObject(Object obj) throws IOException { if (obj == null) { writeNull(); } else if (obj instanceof DERObject) { ((DERObject) obj).encode(this); } else if (obj instanceof DEREncodable) { ((DEREncodable) obj).getDERObject().encode(this); } else { throw new IOException("object not BEREncodable"); } }
Example 70
Project: bitten-master File: BEROutputStream.java View source code |
public void writeObject(Object obj) throws IOException { if (obj == null) { writeNull(); } else if (obj instanceof DERObject) { ((DERObject) obj).encode(this); } else if (obj instanceof DEREncodable) { ((DEREncodable) obj).getDERObject().encode(this); } else { throw new IOException("object not BEREncodable"); } }
Example 71
Project: bnd-master File: TestDirectoryInputStream.java View source code |
public void testComplete() throws IOException {
// DirectoryInputStream din2 = new DirectoryInputStream(new
// File("dir"));
// JarInputStream in = new JarInputStream(din2);
// assertNotNull(in.getManifest());
// JarEntry entry = in.getNextJarEntry();
// while (entry != null) {
// System.err.println(entry.getName());
// entry = in.getNextJarEntry();
// }
//
// in.close();
}
Example 72
Project: Bringers-of-Singularity-master File: PreprocessSMS.java View source code |
public static void main(String[] args) {
smsCorpusToText.main(null);
CorpusPreprocess.main(new String[] { "50000", "1000", "0" });
try {
asketTest.removeMultiplePunctuations(new File("testSentences0.txt"));
asketTest.removeMultiplePunctuations(new File("ppCorpus.txt"));
asketTest.removeMultiplePunctuations(new File("testSentencesCorrection0.txt"));
} catch (IOException e) {
e.printStackTrace();
}
}
Example 73
Project: bugsnag-android-master File: ConfigurationTest.java View source code |
public void testShouldIgnore() { Configuration config = new Configuration("api-key"); // Should not ignore by default assertFalse(config.shouldIgnoreClass("java.io.IOException")); // Should ignore when added to ignoreClasses config.setIgnoreClasses(new String[] { "java.io.IOException" }); assertTrue(config.shouldIgnoreClass("java.io.IOException")); }
Example 74
Project: centipede-master File: Version.java View source code |
public static String get(String packageName) {
String lookFor = "/" + packageName.replace(".", "/") + "/version.properties";
InputStream in = Version.class.getResourceAsStream(lookFor);
Properties p = new Properties();
try {
p.load(in);
} catch (IOException e) {
return null;
}
return p.getProperty(packageName + ".version");
}
Example 75
Project: Cherno-master File: FileUtils.java View source code |
public static String loadText(String path) {
String result = "";
try {
BufferedReader reader = new BufferedReader(new FileReader(path));
String buffer;
while ((buffer = reader.readLine()) != null) {
result += buffer + "\n";
}
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
Example 76
Project: Chute-SDK-V2-Android-master File: JsonTestUtil.java View source code |
public static boolean compare(String first, String second) {
ObjectMapper mapper = new ObjectMapper();
try {
JsonNode tree1 = mapper.readTree(first);
JsonNode tree2 = mapper.readTree(second);
return tree1.equals(tree2);
} catch (IOException e) {
}
throw new RuntimeException("Unable to compare JSON strings");
}
Example 77
Project: coding2017-master File: MiniJVM.java View source code |
public void run(String[] classPaths, String className) throws FileNotFoundException, IOException {
ClassFileLoader loader = new ClassFileLoader();
for (int i = 0; i < classPaths.length; i++) {
loader.addClassPath(classPaths[i]);
}
MethodArea methodArea = MethodArea.getInstance();
methodArea.setClassFileLoader(loader);
ExecutorEngine engine = new ExecutorEngine();
className = className.replace(".", "/");
engine.execute(methodArea.getMainMethod(className));
}
Example 78
Project: CodingSpectator-master File: A_test460.java View source code |
protected void extracted() throws InvocationTargetException { /*[*/ InputStreamReader in = null; try { bar(); } catch (IOException e) { throw new InvocationTargetException(null); } finally { if (in != null) { try { in.close(); } catch (IOException e) { } } /*]*/ } }
Example 79
Project: concordion-dev-master File: FixtureRunner.java View source code |
public void run(final Object fixture) throws IOException {
ConcordionBuilder concordionBuilder = new ConcordionBuilder();
if (fixture.getClass().isAnnotationPresent(FullOGNL.class)) {
concordionBuilder.withEvaluatorFactory(new OgnlEvaluatorFactory());
}
ResultSummary resultSummary = concordionBuilder.build().process(fixture);
resultSummary.print(System.out, fixture);
resultSummary.assertIsSatisfied(fixture);
}
Example 80
Project: CoreNLP-master File: StatisticalCorefFastBenchmarkSlowITest.java View source code |
@Override
public void setUp() throws Exception, IOException {
logger = Redwood.channels(StatisticalCorefFastBenchmarkSlowITest.class);
EXPECTED_F1_SCORE = 56.10;
PROPERTIES_PATH = "edu/stanford/nlp/coref/properties/statistical-english.properties";
WORK_DIR_NAME = "StatisticalCorefBenchmarkTest";
testName = "Statistical English Coref (CoNLL)";
super.setUp();
}
Example 81
Project: DASP-master File: NetUtils.java View source code |
/**
* Gets a free port to listen.
*
* @param ports
* @return
*/
public static Integer getFreePort(int[] ports) {
for (int port : ports) {
try {
ServerSocket ss = new ServerSocket(port);
ss.close();
return port;
} catch (IOException e) {
continue;
}
}
// if we reach here, it means no free port available
return null;
}
Example 82
Project: dc---master File: BEROutputStream.java View source code |
public void writeObject(Object obj) throws IOException { if (obj == null) { writeNull(); } else if (obj instanceof DERObject) { ((DERObject) obj).encode(this); } else if (obj instanceof DEREncodable) { ((DEREncodable) obj).getDERObject().encode(this); } else { throw new IOException("object not BEREncodable"); } }
Example 83
Project: deepnighttwo-master File: CleanDisk.java View source code |
/** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { byte[] e = new byte[1024 * 1024]; OutputStream os = new FileOutputStream("/home/mengzang/eeeeeeeeeee"); int size = 1024 * 110; for (int i = 0; i < size; i++) { os.write(e); if (i % 1024 == 0) { System.out.println((i / 1024) + "G"); } } System.out.println("Finished."); }
Example 84
Project: dgrid-master File: MimeTypeHelperTestCase.java View source code |
public void testMimeTypeHelper() throws IOException {
MimeTypeHelper helper = (MimeTypeHelper) super.getBean(MimeTypeHelper.NAME);
File textFile = File.createTempFile("test-file", ".txt");
textFile.deleteOnExit();
assertEquals("text/plain", helper.getContentType(textFile));
assertEquals("text/plain", helper.getContentType(textFile.getAbsolutePath()));
}
Example 85
Project: diablo-js-master File: ShadowMakerTest.java View source code |
@Test
public void testProcessImage() throws IOException {
URL in = ShadowMakerTest.class.getResource("test.png");
URL out = ShadowMakerTest.class.getResource("out.png");
assertNotNull(in);
assertNotNull(out);
System.out.println(in.getFile());
System.out.println(out.getFile());
ShadowMaker.processImage(in.getFile(), out.getFile());
}
Example 86
Project: dimchat-client-master File: PrintInputStream.java View source code |
@Override public void run() { while (true) { try { String inStr = Client.getNextInput(); if (//disconnect if connection's dead inStr == null) { Message.logError("Connection lost with server."); System.exit(1); } System.out.println(inStr); Client.flushOutput(); } catch (IOException e) { Message.logError("Encountered IOException when reading input next line."); System.exit(-1); } } }
Example 87
Project: dip-master File: TestProperties.java View source code |
public static void main(String[] args) throws IOException {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
InputStream resourceStream = loader.getResourceAsStream("job.properties");
Properties prop = new Properties();
prop.load(resourceStream);
System.out.println(prop.getProperty("systems.hdfsDump.samza.factory"));
}
Example 88
Project: Disaster-Management-Using-Crowdsourcing-master File: Streams.java View source code |
static String readFully(Reader reader) throws IOException {
try {
StringWriter writer = new StringWriter();
char[] buffer = new char[1024];
int count;
while ((count = reader.read(buffer)) != -1) {
writer.write(buffer, 0, count);
}
return writer.toString();
} finally {
StreamUtility.closeQuietly(reader);
}
}
Example 89
Project: Doctors-master File: ConfiguracaoFactory.java View source code |
public static Configuracao getConfiguracao() {
Properties properties = new Properties();
FileInputStream in;
try {
in = new FileInputStream("configuracoes.properties");
properties.load(in);
in.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return new ConfiguracaoPorProperties(properties);
}
Example 90
Project: dokuJClient-master File: StdinReader.java View source code |
public String readStdin() throws IOException {
StringBuilder result = new StringBuilder();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String input;
while ((input = br.readLine()) != null) {
result.append(input + "\n");
}
if (result.length() > 0) {
result.delete(result.length() - 1, result.length());
}
return result.toString();
}
Example 91
Project: DroidNetworking-master File: Streams.java View source code |
static String readFully(Reader reader) throws IOException {
try {
StringWriter writer = new StringWriter();
char[] buffer = new char[1024];
int count;
while ((count = reader.read(buffer)) != -1) {
writer.write(buffer, 0, count);
}
return writer.toString();
} finally {
reader.close();
}
}
Example 92
Project: drools-mas-master File: DialogueHelperTest.java View source code |
@Test(timeout = 3000)
public void testNonExistingEndpoint() {
try {
DialogueHelper helper = new DialogueHelper("http://8.8.8.8:8080/action-agent/services/AsyncAgentService?WSDL", 2000);
} catch (RuntimeException ex) {
if (ex.getCause() != null && !(ex.getCause() instanceof IOException)) {
throw ex;
}
}
}
Example 93
Project: eclipse.jdt.ui-master File: A_test460.java View source code |
protected void extracted() throws InvocationTargetException { /*[*/ InputStreamReader in = null; try { bar(); } catch (IOException e) { throw new InvocationTargetException(null); } finally { if (in != null) { try { in.close(); } catch (IOException e) { } } /*]*/ } }
Example 94
Project: edu-master File: Util.java View source code |
public static String readFileAsString(Reader input) throws IOException {
StringBuilder fileData = new StringBuilder(1000);
BufferedReader reader = new BufferedReader(input);
char[] buf = new char[1024];
int numRead = 0;
while ((numRead = reader.read(buf)) != -1) {
fileData.append(buf, 0, numRead);
}
reader.close();
return fileData.toString();
}
Example 95
Project: EmopAndroid-master File: Streams.java View source code |
static String readFully(Reader reader) throws IOException {
try {
StringWriter writer = new StringWriter();
char[] buffer = new char[1024];
int count;
while ((count = reader.read(buffer)) != -1) {
writer.write(buffer, 0, count);
}
return writer.toString();
} finally {
reader.close();
}
}
Example 96
Project: examensarbete-master File: Main.java View source code |
public static void main(String[] args) {
if (args.length != 1) {
assert false;
}
{
if (args[0].equals("S")) {
Server server = new Server();
server.start();
server.bind(4455, 5544);
} else {
Client client = new Client();
client.start();
try {
client.connect("127.0.0.1", 4455, 5544);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
Example 97
Project: face2face-master File: TransferHandlerMap.java View source code |
public static void initRegistry() throws IOException {
ClientMessage.registerTranferHandler(1000, ClientMessage::transfer2Auth, Auth.CLogin.class);
ClientMessage.registerTranferHandler(1001, ClientMessage::transfer2Auth, Auth.CRegister.class);
ClientMessage.registerTranferHandler(1003, ClientMessage::transfer2Logic, Chat.CPrivateChat.class);
}
Example 98
Project: FB2OnlineConverter-master File: TempFileUtil.java View source code |
public static File createTempDir() throws IOException { File temp = File.createTempFile("temp", Long.toString(System.nanoTime())); if (!(temp.delete())) { throw new IOException("Could not delete temp file: " + temp.getAbsolutePath()); } if (!(temp.mkdir())) { throw new IOException("Could not create temp directory: " + temp.getAbsolutePath()); } return temp; }
Example 99
Project: featurehouse_fstcomp_examples-master File: TankManager.java View source code |
public void aktualisieren() {
original();
if (status != GameManager.SPIELEN) {
if (!sound) {
try {
SoundPlayer.getInstance().playBgSound();
sound = true;
} catch (IOException e) {
e.printStackTrace();
}
}
} else if (sound == true) {
SoundPlayer.getInstance().stopSound();
sound = false;
}
}
Example 100
Project: feluca-master File: TestMultiReader.java View source code |
/** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { MultiVectorReader reader = new MultiVectorReader("data/mltrain", null); int count = 0; for (Vector v = reader.getNextVector(); v != null; v = reader.getNextVector()) { count++; if (count < 20) { System.out.println(v.toString()); } } System.out.println(count); reader.close(); }
Example 101
Project: fred-master File: ByteBufferInputStreamTest.java View source code |
public void testUnsignedRead() throws IOException {
byte[] b = new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0 };
ByteBufferInputStream bis = new ByteBufferInputStream(b);
assertEquals(0xFF, bis.readUnsignedByte());
assertEquals(0xFF00, bis.readUnsignedShort());
try {
bis.readUnsignedByte();
fail();
} catch (EOFException e) {
}
}