code
stringlengths
23
201k
docstring
stringlengths
17
96.2k
func_name
stringlengths
0
235
language
stringclasses
1 value
repo
stringlengths
8
72
path
stringlengths
11
317
url
stringlengths
57
377
license
stringclasses
7 values
void _processCommand(int command) { if (debugoptions) { System.err.println("RECEIVED COMMAND: " + command); } if (__notifhand != null) { __notifhand.receivedNegotiation( TelnetNotificationHandler.RECEIVED_COMMAND, command); } ...
Processes a COMMAND. @param command - option code to be set.
_processCommand
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
void _processDo(int option) throws IOException { if (debugoptions) { System.err.println("RECEIVED DO: " + TelnetOption.getOption(option)); } if (__notifhand != null) { __notifhand.receivedNegotiation( TelnetNotification...
Processes a DO request. @param option - option code to be set. @throws IOException - Exception in I/O.
_processDo
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
void _processDont(int option) throws IOException { if (debugoptions) { System.err.println("RECEIVED DONT: " + TelnetOption.getOption(option)); } if (__notifhand != null) { __notifhand.receivedNegotiation( TelnetNotificat...
Processes a DONT request. @param option - option code to be set. @throws IOException - Exception in I/O.
_processDont
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
void _processWill(int option) throws IOException { if (debugoptions) { System.err.println("RECEIVED WILL: " + TelnetOption.getOption(option)); } if (__notifhand != null) { __notifhand.receivedNegotiation( TelnetNotifica...
Processes a WILL request. @param option - option code to be set. @throws IOException - Exception in I/O.
_processWill
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
void _processWont(int option) throws IOException { if (debugoptions) { System.err.println("RECEIVED WONT: " + TelnetOption.getOption(option)); } if (__notifhand != null) { __notifhand.receivedNegotiation( TelnetNotifica...
Processes a WONT request. @param option - option code to be set. @throws IOException - Exception in I/O.
_processWont
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
void _processSuboption(int suboption[], int suboptionLength) throws IOException { if (debug) { System.err.println("PROCESS SUBOPTION."); } /* open TelnetOptionHandler functionality (start)*/ if (suboptionLength > 0) { if (optionHandlers[su...
Processes a suboption negotiation. @param suboption - subnegotiation data received @param suboptionLength - length of data received @throws IOException - Exception in I/O.
_processSuboption
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
final synchronized void _sendTerminalType() throws IOException { if (debug) { System.err.println("SEND TERMINAL-TYPE: " + terminalType); } if (terminalType != null) { _output_.write(_COMMAND_SB); _output_.write(_COMMAND_IS); ...
Sends terminal type information. @throws IOException - Exception in I/O. *
_sendTerminalType
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
final synchronized void _sendSubnegotiation(int subn[]) throws IOException { if (debug) { System.err.println("SEND SUBNEGOTIATION: "); if (subn != null) { System.err.println(Arrays.toString(subn)); } } if (subn != nu...
Manages subnegotiation for Terminal Type. @param subn - subnegotiation data to be sent @throws IOException - Exception in I/O.
_sendSubnegotiation
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
final synchronized void _sendCommand(byte cmd) throws IOException { _output_.write(TelnetCommand.IAC); _output_.write(cmd); _output_.flush(); }
Sends a command, automatically adds IAC prefix and flushes the output. @param cmd - command data to be sent @throws IOException - Exception in I/O. @since 3.0
_sendCommand
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
final synchronized void _processAYTResponse() { if (!aytFlag) { synchronized (aytMonitor) { aytFlag = true; aytMonitor.notifyAll(); } } }
Processes the response of an AYT *
_processAYTResponse
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
@Override protected void _connectAction_() throws IOException { /* (start). BUGFIX: clean the option info for each connection*/ for (int ii = 0; ii < TelnetOption.MAX_OPTION_VALUE + 1; ii++) { _doResponse[ii] = 0; _willResponse[ii] = 0; _options[ii] = ...
Called upon connection. @throws IOException - Exception in I/O. *
_connectAction_
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
final synchronized void _sendDo(int option) throws IOException { if (debug || debugoptions) { System.err.println("DO: " + TelnetOption.getOption(option)); } _output_.write(_COMMAND_DO); _output_.write(option); /* Code Section added for sending the neg...
Sends a DO. @param option - Option code. @throws IOException - Exception in I/O.
_sendDo
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
final synchronized void _requestDo(int option) throws IOException { if ((_doResponse[option] == 0 && _stateIsDo(option)) || _requestedDo(option)) { return ; } _setWantDo(option); ++_doResponse[option]; _sendDo(option); }
Requests a DO. @param option - Option code. @throws IOException - Exception in I/O.
_requestDo
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
final synchronized void _sendDont(int option) throws IOException { if (debug || debugoptions) { System.err.println("DONT: " + TelnetOption.getOption(option)); } _output_.write(_COMMAND_DONT); _output_.write(option); /* Code Section added for sending t...
Sends a DONT. @param option - Option code. @throws IOException - Exception in I/O.
_sendDont
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
final synchronized void _requestDont(int option) throws IOException { if ((_doResponse[option] == 0 && _stateIsDont(option)) || _requestedDont(option)) { return ; } _setWantDont(option); ++_doResponse[option]; _sendDont(option); }
Requests a DONT. @param option - Option code. @throws IOException - Exception in I/O.
_requestDont
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
final synchronized void _sendWill(int option) throws IOException { if (debug || debugoptions) { System.err.println("WILL: " + TelnetOption.getOption(option)); } _output_.write(_COMMAND_WILL); _output_.write(option); /* Code Section added for sending t...
Sends a WILL. @param option - Option code. @throws IOException - Exception in I/O.
_sendWill
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
final synchronized void _requestWill(int option) throws IOException { if ((_willResponse[option] == 0 && _stateIsWill(option)) || _requestedWill(option)) { return ; } _setWantWill(option); ++_doResponse[option]; _sendWill(option); }
Requests a WILL. @param option - Option code. @throws IOException - Exception in I/O.
_requestWill
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
final synchronized void _sendWont(int option) throws IOException { if (debug || debugoptions) { System.err.println("WONT: " + TelnetOption.getOption(option)); } _output_.write(_COMMAND_WONT); _output_.write(option); /* Code Section added for sending t...
Sends a WONT. @param option - Option code. @throws IOException - Exception in I/O.
_sendWont
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
final synchronized void _requestWont(int option) throws IOException { if ((_willResponse[option] == 0 && _stateIsWont(option)) || _requestedWont(option)) { return ; } _setWantWont(option); ++_doResponse[option]; _sendWont(option); }
Requests a WONT. @param option - Option code. @throws IOException - Exception in I/O.
_requestWont
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
final synchronized void _sendByte(int b) throws IOException { _output_.write(b); /* Code Section added for supporting spystreams (start)*/ _spyWrite(b); /* Code Section added for supporting spystreams (end)*/ }
Sends a byte. @param b - byte to send @throws IOException - Exception in I/O.
_sendByte
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
final boolean _sendAYT(long timeout) throws IOException, IllegalArgumentException, InterruptedException { boolean retValue = false; synchronized (aytMonitor) { synchronized (this) { aytFlag = false; _output_.write(_COMMAND_AYT); ...
Sends an Are You There sequence and waits for the result. @param timeout - Time to wait for a response (millis.) @throws IOException - Exception in I/O. @throws IllegalArgumentException - Illegal argument @throws InterruptedException - Interrupted during wait. @return true if AYT received a response, false otherwise
_sendAYT
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
void addOptionHandler(TelnetOptionHandler opthand) throws InvalidTelnetOptionException, IOException { int optcode = opthand.getOptionCode(); if (TelnetOption.isValidOption(optcode)) { if (optionHandlers[optcode] == null) { optionHandlers[optcode] =...
Registers a new TelnetOptionHandler for this telnet to use. @param opthand - option handler to be registered. @throws InvalidTelnetOptionException - The option code is invalid. @throws IOException on error
addOptionHandler
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
void deleteOptionHandler(int optcode) throws InvalidTelnetOptionException, IOException { if (TelnetOption.isValidOption(optcode)) { if (optionHandlers[optcode] == null) { throw (new InvalidTelnetOptionException( "Unregistered option", o...
Unregisters a TelnetOptionHandler. @param optcode - Code of the option to be unregistered. @throws InvalidTelnetOptionException - The option code is invalid. @throws IOException on error
deleteOptionHandler
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
void _registerSpyStream(OutputStream spystream) { spyStream = spystream; }
Registers an OutputStream for spying what's going on in the Telnet session. @param spystream - OutputStream on which session activity will be echoed. *
_registerSpyStream
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
void _spyRead(int ch) { OutputStream spy = spyStream; if (spy != null) { try { if (ch != '\r') // never write '\r' on its own { if (ch == '\n') { spy.write('\r'); // add '\...
Sends a read char on the spy stream. @param ch - character read from the session *
_spyRead
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
void _spyWrite(int ch) { if (!(_stateIsDo(TelnetOption.ECHO) && _requestedDo(TelnetOption.ECHO))) { OutputStream spy = spyStream; if (spy != null) { try { spy.write(ch); spy.flush(...
Sends a written char on the spy stream. @param ch - character written to the session *
_spyWrite
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
public void registerNotifHandler(TelnetNotificationHandler notifhand) { __notifhand = notifhand; }
Registers a notification handler to which will be sent notifications of received telnet option negotiation commands. @param notifhand - TelnetNotificationHandler to be registered *
registerNotifHandler
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/Telnet.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/Telnet.java
Apache-2.0
void _flushOutputStream() throws IOException { _output_.flush(); }
Construct an instance with the specified terminal type. @param termtype the terminal type to use, e.g. {@code VT100}
_flushOutputStream
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
Apache-2.0
void _closeOutputStream() throws IOException { _output_.close(); }
Construct an instance with the specified terminal type. @param termtype the terminal type to use, e.g. {@code VT100}
_closeOutputStream
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
Apache-2.0
@Override protected void _connectAction_() throws IOException { super._connectAction_(); TelnetInputStream tmp = new TelnetInputStream(_input_, this, readerThread); if(readerThread) { tmp._start(); } // __input CANNOT refer to the TelnetInputStream. W...
Handles special connection requirements. @exception IOException If an error occurs during connection setup. *
_connectAction_
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
Apache-2.0
@Override public void disconnect() throws IOException { if (__input != null) { __input.close(); } if (__output != null) { __output.close(); } super.disconnect(); }
Disconnects the telnet session, closing the input and output streams as well as the socket. If you have references to the input and output streams of the telnet connection, you should not close them yourself, but rather call disconnect to properly close the connection. *
disconnect
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
Apache-2.0
public OutputStream getOutputStream() { return __output; }
Returns the telnet connection output stream. You should not close the stream when you finish with it. Rather, you should call {@link #disconnect disconnect }. @return The telnet connection output stream. *
getOutputStream
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
Apache-2.0
public InputStream getInputStream() { return __input; }
Returns the telnet connection input stream. You should not close the stream when you finish with it. Rather, you should call {@link #disconnect disconnect }. @return The telnet connection input stream. *
getInputStream
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
Apache-2.0
public boolean getLocalOptionState(int option) { /* BUG (option active when not already acknowledged) (start)*/ return (_stateIsWill(option) && _requestedWill(option)); /* BUG (option active when not already acknowledged) (end)*/ }
Returns the state of the option on the local side. @param option - Option to be checked. @return The state of the option on the local side. *
getLocalOptionState
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
Apache-2.0
public boolean getRemoteOptionState(int option) { /* BUG (option active when not already acknowledged) (start)*/ return (_stateIsDo(option) && _requestedDo(option)); /* BUG (option active when not already acknowledged) (end)*/ }
Returns the state of the option on the remote side. @param option - Option to be checked. @return The state of the option on the remote side. *
getRemoteOptionState
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
Apache-2.0
public boolean sendAYT(long timeout) throws IOException, IllegalArgumentException, InterruptedException { return (_sendAYT(timeout)); }
Sends an Are You There sequence and waits for the result. @param timeout - Time to wait for a response (millis.) @return true if AYT received a response, false otherwise @throws InterruptedException on error @throws IllegalArgumentException on error @throws IOException on error *
sendAYT
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
Apache-2.0
public void sendSubnegotiation(int[] message) throws IOException, IllegalArgumentException { if (message.length < 1) { throw new IllegalArgumentException("zero length message"); } _sendSubnegotiation(message); }
Sends a protocol-specific subnegotiation message to the remote peer. {@link TelnetClient} will add the IAC SB &amp; IAC SE framing bytes; the first byte in {@code message} should be the appropriate telnet option code. <p> This method does not wait for any response. Subnegotiation messages sent by the remote end can be...
sendSubnegotiation
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
Apache-2.0
public void sendCommand(byte command) throws IOException, IllegalArgumentException { _sendCommand(command); }
Sends a command byte to the remote peer, adding the IAC prefix. <p> This method does not wait for any response. Messages sent by the remote end can be handled by registering an approrpriate {@link TelnetOptionHandler}. </p> @param command the code for the command @throws IOException if an I/O error occurs while writi...
sendCommand
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
Apache-2.0
@Override public void addOptionHandler(TelnetOptionHandler opthand) throws InvalidTelnetOptionException, IOException { super.addOptionHandler(opthand); }
Registers a new TelnetOptionHandler for this telnet client to use. @param opthand - option handler to be registered. @throws InvalidTelnetOptionException on error @throws IOException on error *
addOptionHandler
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
Apache-2.0
@Override public void deleteOptionHandler(int optcode) throws InvalidTelnetOptionException, IOException { super.deleteOptionHandler(optcode); }
Unregisters a TelnetOptionHandler. @param optcode - Code of the option to be unregistered. @throws InvalidTelnetOptionException on error @throws IOException on error *
deleteOptionHandler
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
Apache-2.0
public void registerSpyStream(OutputStream spystream) { super._registerSpyStream(spystream); }
Registers an OutputStream for spying what's going on in the TelnetClient session. @param spystream - OutputStream on which session activity will be echoed. *
registerSpyStream
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
Apache-2.0
@Override public void registerNotifHandler(TelnetNotificationHandler notifhand) { super.registerNotifHandler(notifhand); }
Registers a notification handler to which will be sent notifications of received telnet option negotiation commands. @param notifhand - TelnetNotificationHandler to be registered *
registerNotifHandler
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
Apache-2.0
public void setReaderThread(boolean flag) { readerThread = flag; }
Sets the status of the reader thread. <p> When enabled, a seaparate internal reader thread is created for new connections to read incoming data as it arrives. This results in immediate handling of option negotiation, notifications, etc. (at least until the fixed-size internal buffer fills up). Otherwise, no thread is ...
setReaderThread
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
Apache-2.0
public boolean getReaderThread() { return (readerThread); }
Gets the status of the reader thread. @return true if the reader thread is enabled, false otherwise *
getReaderThread
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
Apache-2.0
public synchronized void registerInputListener(TelnetInputListener listener) { this.inputListener = listener; }
Register a listener to be notified when new incoming data is available to be read on the {@link #getInputStream input stream}. Only one listener is supported at a time. <p> More precisely, notifications are issued whenever the number of bytes available for immediate reading (i.e., the value returned by {@link InputStr...
registerInputListener
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
Apache-2.0
public synchronized void unregisterInputListener() { this.inputListener = null; }
Unregisters the current {@link TelnetInputListener}, if any. @since 3.0 *
unregisterInputListener
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
Apache-2.0
void notifyInputListener() { TelnetInputListener listener; synchronized (this) { listener = this.inputListener; } if (listener != null) { listener.telnetInputAvailable(); } }
Unregisters the current {@link TelnetInputListener}, if any. @since 3.0 *
notifyInputListener
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
Apache-2.0
public static final String getCommand(int code) { return __commandString[__FIRST_COMMAND - code]; }
Returns the string representation of the telnet protocol command corresponding to the given command code. <p> @param code The command code of the telnet protocol command. @return The string representation of the telnet protocol command. *
getCommand
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetCommand.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetCommand.java
Apache-2.0
public static final boolean isValidCommand(int code) { return (code <= __FIRST_COMMAND && code >= __LAST_COMMAND); }
Determines if a given command code is valid. Returns true if valid, false if not. <p> @param code The command code to test. @return True if the command code is valid, false if not.
isValidCommand
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetCommand.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetCommand.java
Apache-2.0
private int __read(boolean mayBlock) throws IOException { int ch; while (true) { // If there is no more data AND we were told not to block, // just return WOULD_BLOCK (-2). (More efficient than exception.) if(!mayBlock && super.available() == 0) { ...
Get the next byte of data. IAC commands are processed internally and do not return data. @param mayBlock true if method is allowed to block @return the next byte of data, or -1 (EOF) if end of stread reached, or -2 (WOULD_BLOCK) if mayBlock is false and there is no data available
__read
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
Apache-2.0
private boolean __processChar(int ch) throws InterruptedException { // Critical section because we're altering __bytesAvailable, // __queueTail, and the contents of _queue. boolean bufferWasEmpty; synchronized (__queue) { bufferWasEmpty = (__bytesAvailable == 0); ...
Get the next byte of data. IAC commands are processed internally and do not return data. @param mayBlock true if method is allowed to block @return the next byte of data, or -1 (EOF) if end of stread reached, or -2 (WOULD_BLOCK) if mayBlock is false and there is no data available
__processChar
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
Apache-2.0
@Override public int read() throws IOException { // Critical section because we're altering __bytesAvailable, // __queueHead, and the contents of _queue in addition to // testing value of __hasReachedEOF. synchronized (__queue) { while (true) { ...
Get the next byte of data. IAC commands are processed internally and do not return data. @param mayBlock true if method is allowed to block @return the next byte of data, or -1 (EOF) if end of stread reached, or -2 (WOULD_BLOCK) if mayBlock is false and there is no data available
read
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
Apache-2.0
@Override public int read(byte buffer[]) throws IOException { return read(buffer, 0, buffer.length); }
Reads the next number of bytes from the stream into an array and returns the number of bytes read. Returns -1 if the end of the stream has been reached. <p> @param buffer The byte array in which to store the data. @return The number of bytes read. Returns -1 if the end of the message has been reached. @excep...
read
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
Apache-2.0
@Override public int read(byte buffer[], int offset, int length) throws IOException { int ch, off; if (length < 1) { return 0; } // Critical section because run() may change __bytesAvailable synchronized (__queue) { if (length > __bytesAv...
Reads the next number of bytes from the stream into an array and returns the number of bytes read. Returns -1 if the end of the message has been reached. The characters are stored in the array starting from the given offset and up to the length specified. <p> @param buffer The byte array in which to store the data. @...
read
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
Apache-2.0
@Override public boolean markSupported() { return false; }
Returns false. Mark is not supported. **
markSupported
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
Apache-2.0
@Override public int available() throws IOException { // Critical section because run() may change __bytesAvailable synchronized (__queue) { if (__threaded) { // Must not call super.available when running threaded: NET-466 return __bytesAvailable; ...
Returns false. Mark is not supported. **
available
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
Apache-2.0
@Override public void close() throws IOException { // Completely disregard the fact thread may still be running. // We can't afford to block on this close by waiting for // thread to terminate because few if any JVM's will actually // interrupt a system read() from the interrupt(...
Returns false. Mark is not supported. **
close
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
Apache-2.0
@Override public void run() { int ch; try { _outerLoop: while (!__isClosed) { try { if ((ch = __read(true)) < 0) { break; } } catch (In...
Returns false. Mark is not supported. **
run
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
Apache-2.0
public static final String getOption(int code) { if(__optionString[code].length() == 0) { return "UNASSIGNED"; } else { return __optionString[code]; } }
Returns the string representation of the telnet protocol option corresponding to the given option code. @param code The option code of the telnet protocol option @return The string representation of the telnet protocol option. *
getOption
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetOption.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOption.java
Apache-2.0
public static final boolean isValidOption(int code) { return (code <= __LAST_OPTION); }
Determines if a given option code is valid. Returns true if valid, false if not. @param code The option code to test. @return True if the option code is valid, false if not.
isValidOption
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetOption.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOption.java
Apache-2.0
public int getOptionCode() { return (optionCode); }
Returns the option code for this option. <p> @return Option code. *
getOptionCode
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
Apache-2.0
public boolean getAcceptLocal() { return (acceptLocal); }
Returns a boolean indicating whether to accept a DO request coming from the other end. <p> @return true if a DO request shall be accepted. *
getAcceptLocal
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
Apache-2.0
public boolean getAcceptRemote() { return (acceptRemote); }
Returns a boolean indicating whether to accept a WILL request coming from the other end. <p> @return true if a WILL request shall be accepted. *
getAcceptRemote
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
Apache-2.0
public void setAcceptLocal(boolean accept) { acceptLocal = accept; }
Set behaviour of the option for DO requests coming from the other end. <p> @param accept - if true, subsequent DO requests will be accepted. *
setAcceptLocal
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
Apache-2.0
public void setAcceptRemote(boolean accept) { acceptRemote = accept; }
Set behaviour of the option for WILL requests coming from the other end. <p> @param accept - if true, subsequent WILL requests will be accepted. *
setAcceptRemote
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
Apache-2.0
public boolean getInitLocal() { return (initialLocal); }
Returns a boolean indicating whether to send a WILL request to the other end upon connection. <p> @return true if a WILL request shall be sent upon connection. *
getInitLocal
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
Apache-2.0
public boolean getInitRemote() { return (initialRemote); }
Returns a boolean indicating whether to send a DO request to the other end upon connection. <p> @return true if a DO request shall be sent upon connection. *
getInitRemote
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
Apache-2.0
public void setInitLocal(boolean init) { initialLocal = init; }
Tells this option whether to send a WILL request upon connection. <p> @param init - if true, a WILL request will be sent upon subsequent connections. *
setInitLocal
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
Apache-2.0
public void setInitRemote(boolean init) { initialRemote = init; }
Tells this option whether to send a DO request upon connection. <p> @param init - if true, a DO request will be sent upon subsequent connections. *
setInitRemote
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
Apache-2.0
public int[] answerSubnegotiation(int suboptionData[], int suboptionLength) { return null; }
Method called upon reception of a subnegotiation for this option coming from the other end. <p> This implementation returns null, and must be overridden by the actual TelnetOptionHandler to specify which response must be sent for the subnegotiation request. <p> @param suboptionData - the sequence received, without IAC ...
answerSubnegotiation
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
Apache-2.0
public int[] startSubnegotiationLocal() { return null; }
This method is invoked whenever this option is acknowledged active on the local end (TelnetClient sent a WILL, remote side sent a DO). The method is used to specify a subnegotiation sequence that will be sent by TelnetClient when the option is activated. <p> This implementation returns null, and must be overridden by t...
startSubnegotiationLocal
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
Apache-2.0
public int[] startSubnegotiationRemote() { return null; }
This method is invoked whenever this option is acknowledged active on the remote end (TelnetClient sent a DO, remote side sent a WILL). The method is used to specify a subnegotiation sequence that will be sent by TelnetClient when the option is activated. <p> This implementation returns null, and must be overridden by ...
startSubnegotiationRemote
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
Apache-2.0
boolean getWill() { return willFlag; }
Returns a boolean indicating whether a WILL request sent to the other side has been acknowledged. <p> @return true if a WILL sent to the other side has been acknowledged. *
getWill
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
Apache-2.0
void setWill(boolean state) { willFlag = state; }
Tells this option whether a WILL request sent to the other side has been acknowledged (invoked by TelnetClient). <p> @param state - if true, a WILL request has been acknowledged. *
setWill
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
Apache-2.0
boolean getDo() { return doFlag; }
Returns a boolean indicating whether a DO request sent to the other side has been acknowledged. <p> @return true if a DO sent to the other side has been acknowledged. *
getDo
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
Apache-2.0
void setDo(boolean state) { doFlag = state; }
Tells this option whether a DO request sent to the other side has been acknowledged (invoked by TelnetClient). <p> @param state - if true, a DO request has been acknowledged. *
setDo
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java
Apache-2.0
@Override public void write(int ch) throws IOException { synchronized (__client) { ch &= 0xff; if (__client._requestedWont(TelnetOption.BINARY)) // i.e. ASCII { if (__lastWasCR) { if (__convertCRtoCRLF) ...
Writes a byte to the stream. <p> @param ch The byte to write. @exception IOException If an error occurs while writing to the underlying stream. *
write
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetOutputStream.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOutputStream.java
Apache-2.0
@Override public void write(byte buffer[]) throws IOException { write(buffer, 0, buffer.length); }
Writes a byte array to the stream. <p> @param buffer The byte array to write. @exception IOException If an error occurs while writing to the underlying stream. *
write
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetOutputStream.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOutputStream.java
Apache-2.0
@Override public void write(byte buffer[], int offset, int length) throws IOException { synchronized (__client) { while (length-- > 0) { write(buffer[offset++]); } } }
Writes a number of bytes from a byte array to the stream starting from a given offset. <p> @param buffer The byte array to write. @param offset The offset into the array at which to start copying data. @param length The number of bytes to write. @exception IOException If an error occurs while writing to the underlyi...
write
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TelnetOutputStream.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TelnetOutputStream.java
Apache-2.0
@Override public int[] answerSubnegotiation(int suboptionData[], int suboptionLength) { if ((suboptionData != null) && (suboptionLength > 1) && (termType != null)) { if ((suboptionData[0] == TERMINAL_TYPE) && (suboptionData[1] == TERMINAL_TYPE_SEND)) ...
Implements the abstract method of TelnetOptionHandler. <p> @param suboptionData - the sequence received, without IAC SB &amp; IAC SE @param suboptionLength - the length of data in suboption_data <p> @return terminal type information *
answerSubnegotiation
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/TerminalTypeOptionHandler.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/TerminalTypeOptionHandler.java
Apache-2.0
@Override public int[] startSubnegotiationLocal() { int nCompoundWindowSize = m_nWidth * 0x10000 + m_nHeight; int nResponseSize = 5; int nIndex; int nShift; int nTurnedOnBits; if ((m_nWidth % 0x100) == 0xFF) { nResponseSize += 1; } if...
Implements the abstract method of TelnetOptionHandler. This will send the client Height and Width to the server. <p> @return array to send to remote system *
startSubnegotiationLocal
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/telnet/WindowSizeOptionHandler.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/telnet/WindowSizeOptionHandler.java
Apache-2.0
@Override public Iterator<EventListener> iterator() { return __listeners.iterator(); }
Return an {@link Iterator} for the {@link EventListener} instances. @return an {@link Iterator} for the {@link EventListener} instances @since 2.0 TODO Check that this is a good defensive strategy
iterator
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/util/ListenerList.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/util/ListenerList.java
Apache-2.0
public static boolean enableColor() { return enableColor; }
<pre> FINEST -> TRACE FINER -> DEBUG FINE -> DEBUG CONFIG -> INFO INFO -> INFO WARNING -> WARN SEVERE -> ERROR </pre> @see org.slf4j.bridge.SLF4JBridgeHandler @author hengyunabc 2017-05-03
enableColor
java
alibaba/arthas
common/src/main/java/com/taobao/arthas/common/AnsiLog.java
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/AnsiLog.java
Apache-2.0
public static Level level(Level level) { Level old = LEVEL; LEVEL = level; return old; }
set logger Level @see java.util.logging.Level @param level @return
level
java
alibaba/arthas
common/src/main/java/com/taobao/arthas/common/AnsiLog.java
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/AnsiLog.java
Apache-2.0
public static List<String> runNative(String cmdToRun) { String[] cmd = cmdToRun.split(" "); return runNative(cmd); }
Executes a command on the native command line and returns the result. @param cmdToRun Command to run @return A list of Strings representing the result of the command, or empty string if the command failed
runNative
java
alibaba/arthas
common/src/main/java/com/taobao/arthas/common/ExecutingCommand.java
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/ExecutingCommand.java
Apache-2.0
public static List<String> runNative(String[] cmdToRunWithArgs) { Process p = null; try { p = Runtime.getRuntime().exec(cmdToRunWithArgs); } catch (SecurityException e) { AnsiLog.trace("Couldn't run command {}:", Arrays.toString(cmdToRunWithArgs)); AnsiLog.tra...
Executes a command on the native command line and returns the result line by line. @param cmdToRunWithArgs Command to run and args, in an array @return A list of Strings representing the result of the command, or empty string if the command failed
runNative
java
alibaba/arthas
common/src/main/java/com/taobao/arthas/common/ExecutingCommand.java
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/ExecutingCommand.java
Apache-2.0
public static String getFirstAnswer(String cmd2launch) { return getAnswerAt(cmd2launch, 0); }
Return first line of response for selected command. @param cmd2launch String command to be launched @return String or empty string if command failed
getFirstAnswer
java
alibaba/arthas
common/src/main/java/com/taobao/arthas/common/ExecutingCommand.java
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/ExecutingCommand.java
Apache-2.0
public static String getAnswerAt(String cmd2launch, int answerIdx) { List<String> sa = ExecutingCommand.runNative(cmd2launch); if (answerIdx >= 0 && answerIdx < sa.size()) { return sa.get(answerIdx); } return ""; }
Return response on selected line index (0-based) after running selected command. @param cmd2launch String command to be launched @param answerIdx int index of line in response of the command @return String whole line in response or empty string if invalid index or running of command fails
getAnswerAt
java
alibaba/arthas
common/src/main/java/com/taobao/arthas/common/ExecutingCommand.java
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/ExecutingCommand.java
Apache-2.0
public static void writeByteArrayToFile(final File file, final byte[] data) throws IOException { writeByteArrayToFile(file, data, false); }
Writes a byte array to a file creating the file if it does not exist. <p> NOTE: As from v1.3, the parent directories of the file will be created if they do not exist. @param file the file to write to @param data the content to write to the file @throws IOException in case of an I/O error @since 1.1
writeByteArrayToFile
java
alibaba/arthas
common/src/main/java/com/taobao/arthas/common/FileUtils.java
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/FileUtils.java
Apache-2.0
public static void writeByteArrayToFile(final File file, final byte[] data, final boolean append) throws IOException { writeByteArrayToFile(file, data, 0, data.length, append); }
Writes a byte array to a file creating the file if it does not exist. @param file the file to write to @param data the content to write to the file @param append if {@code true}, then bytes will be added to the end of the file rather than overwriting @throws IOException in case of an I/O error @since...
writeByteArrayToFile
java
alibaba/arthas
common/src/main/java/com/taobao/arthas/common/FileUtils.java
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/FileUtils.java
Apache-2.0
public static void writeByteArrayToFile(final File file, final byte[] data, final int off, final int len) throws IOException { writeByteArrayToFile(file, data, off, len, false); }
Writes {@code len} bytes from the specified byte array starting at offset {@code off} to a file, creating the file if it does not exist. @param file the file to write to @param data the content to write to the file @param off the start offset in the data @param len the number of bytes to write @throws IOException in...
writeByteArrayToFile
java
alibaba/arthas
common/src/main/java/com/taobao/arthas/common/FileUtils.java
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/FileUtils.java
Apache-2.0
public static void writeByteArrayToFile(final File file, final byte[] data, final int off, final int len, final boolean append) throws IOException { FileOutputStream out = null; try { out = openOutputStream(file, append); out.write(data, off, len); } finally { IOUtils.close(out); } }
Writes {@code len} bytes from the specified byte array starting at offset {@code off} to a file, creating the file if it does not exist. @param file the file to write to @param data the content to write to the file @param off the start offset in the data @param len the number of bytes to write @param append ...
writeByteArrayToFile
java
alibaba/arthas
common/src/main/java/com/taobao/arthas/common/FileUtils.java
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/FileUtils.java
Apache-2.0
public static FileOutputStream openOutputStream(final File file, final boolean append) throws IOException { if (file.exists()) { if (file.isDirectory()) { throw new IOException("File '" + file + "' exists but is a directory"); } if (!file.canWrite()) { throw new IOException("File '" + file + "' canno...
Opens a {@link FileOutputStream} for the specified file, checking and creating the parent directory if it does not exist. <p> At the end of the method either the stream will be successfully opened, or an exception will have been thrown. <p> The parent directory will be created if it does not exist. The file will be cre...
openOutputStream
java
alibaba/arthas
common/src/main/java/com/taobao/arthas/common/FileUtils.java
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/FileUtils.java
Apache-2.0
public static byte[] readFileToByteArray(final File file) throws IOException { InputStream in = null; try { in = new FileInputStream(file); return IOUtils.getBytes(in); } finally { IOUtils.close(in); } }
Reads the contents of a file into a byte array. The file is always closed. @param file the file to read, must not be {@code null} @return the file contents, never {@code null} @throws IOException in case of an I/O error @since 1.1
readFileToByteArray
java
alibaba/arthas
common/src/main/java/com/taobao/arthas/common/FileUtils.java
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/FileUtils.java
Apache-2.0
public static byte[] getBytes(InputStream input) throws IOException { ByteArrayOutputStream result = new ByteArrayOutputStream(); copy(input, result); result.close(); return result.toByteArray(); }
@return a byte[] containing the information contained in the specified InputStream. @throws java.io.IOException
getBytes
java
alibaba/arthas
common/src/main/java/com/taobao/arthas/common/IOUtils.java
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/IOUtils.java
Apache-2.0
public static IOException close(InputStream input) { return close((Closeable) input); }
@return a byte[] containing the information contained in the specified InputStream. @throws java.io.IOException
close
java
alibaba/arthas
common/src/main/java/com/taobao/arthas/common/IOUtils.java
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/IOUtils.java
Apache-2.0
public static IOException close(OutputStream output) { return close((Closeable) output); }
@return a byte[] containing the information contained in the specified InputStream. @throws java.io.IOException
close
java
alibaba/arthas
common/src/main/java/com/taobao/arthas/common/IOUtils.java
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/IOUtils.java
Apache-2.0
public static IOException close(final Reader input) { return close((Closeable) input); }
@return a byte[] containing the information contained in the specified InputStream. @throws java.io.IOException
close
java
alibaba/arthas
common/src/main/java/com/taobao/arthas/common/IOUtils.java
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/IOUtils.java
Apache-2.0
public static IOException close(final Writer output) { return close((Closeable) output); }
@return a byte[] containing the information contained in the specified InputStream. @throws java.io.IOException
close
java
alibaba/arthas
common/src/main/java/com/taobao/arthas/common/IOUtils.java
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/IOUtils.java
Apache-2.0
public static IOException close(final Closeable closeable) { try { if (closeable != null) { closeable.close(); } } catch (final IOException ioe) { return ioe; } return null; }
@return a byte[] containing the information contained in the specified InputStream. @throws java.io.IOException
close
java
alibaba/arthas
common/src/main/java/com/taobao/arthas/common/IOUtils.java
https://github.com/alibaba/arthas/blob/master/common/src/main/java/com/taobao/arthas/common/IOUtils.java
Apache-2.0