本文整理汇总了Java中ua.at.tsvetkov.util.Log类的典型用法代码示例。如果您正苦于以下问题:Java Log类的具体用法?Java Log怎么用?Java Log使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Log类属于ua.at.tsvetkov.util包,在下文中一共展示了Log类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import ua.at.tsvetkov.util.Log; //导入依赖的package包/类
@Override
public void parse(InputStream inputStream) throws Exception {
if (inputStream == null) {
Log.w("InputStream is null. Parsing aborted.");
return;
}
// BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
// String line;
// StringBuffer buffer = new StringBuffer();
// while ((line = reader.readLine()) != null) {
// buffer.append(line);
// }
// process(buffer.toString().trim());
// better performance
ByteArrayOutputStream result = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length;
while ((length = inputStream.read(buffer)) != -1) {
result.write(buffer, 0, length);
}
process(result.toString("UTF-8"));
}
示例2: saveToFile
import ua.at.tsvetkov.util.Log; //导入依赖的package包/类
private void saveToFile() throws IOException {
File f = new File(cacheFileName);
if (!request.isNeedToRewriteFile() && f.exists() && f.length() > 0) {
if (DataProcessor.getInstance().getConfiguration().isLogEnabled()) {
Log.w(FILE_EXIST + cacheFileName);
}
return;
}
FileOutputStream out = new FileOutputStream(cacheFileName);
byte[] buffer = new byte[BUFFER];
int bytesRead = -1;
inputStream = request.getInputStream();
while ((bytesRead = inputStream.read(buffer)) != -1) {
out.write(buffer, 0, bytesRead);
}
out.flush();
out.close();
inputStream.close();
inputStream = new FileInputStream(cacheFileName);
}
示例3: init
import ua.at.tsvetkov.util.Log; //导入依赖的package包/类
/**
* Build new data processor with given configuration
*
* @param configuration new configuration
*/
public synchronized void init(DataProcessorConfiguration configuration) {
if (configuration == null) {
throw new IllegalArgumentException(ERROR_INIT_CONFIG_WITH_NULL);
}
if (this.configuration == null) {
if (configuration.isLogEnabled) {
Log.d(LOG_INIT_CONFIG);
}
this.configuration = configuration;
} else {
Log.w(WARNING_RE_INIT_CONFIG);
}
if (configuration.isThreadPoolEnabled) {
threadPool = new DataProcessorThreadPool();
}
if (configuration.isCacheEnabled()) {
processors = new ProcessorsCache(configuration.getCacheSize());
}
}
示例4: toString
import ua.at.tsvetkov.util.Log; //导入依赖的package包/类
/**
* Return composed URL string from parts or null if not builded
*/
@Override
public String toString() {
if (sb != null) {
if (configuration.isCheckingRequestStringEnabled()) {
try {
return URLEncoder.encode(sb.toString(), encoding);
} catch (UnsupportedEncodingException e) {
Log.e(WRONG_URL, e);
return "";
}
} else {
return sb.toString();
}
} else {
if (configuration.isLogEnabled()) {
Log.w(REQUEST_IS_NOT_BUILD);
}
return null;
}
}
示例5: enableStrictMode
import ua.at.tsvetkov.util.Log; //导入依赖的package包/类
/**
* Enable StrictMode in the app. Put call in the first called onCreate() method in Application or Activity.
*
* @param aContext the app Context
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void enableStrictMode(Context aContext) {
try {
int appFlags = aContext.getApplicationInfo().flags;
if ((appFlags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectActivityLeaks().detectLeakedSqlLiteObjects().detectLeakedClosableObjects().penaltyLog().penaltyDeath().build());
}
isStrictMode = true;
Log.i("StrictMode is enabled.");
} catch (Throwable throwable) {
isStrictMode = false;
Log.i("StrictMode is not supported. Skipping...");
}
}
示例6: fromInputStream
import ua.at.tsvetkov.util.Log; //导入依赖的package包/类
/**
* Computes and returns the final hash value for this InputStream data
*
* @param in InputStream
* @return null if has error or hash value
*/
public static byte[] fromInputStream(InputStream in) {
MessageDigest digester;
try {
digester = MessageDigest.getInstance("MD5");
byte[] bytes = new byte[8192];
int byteCount;
while ((byteCount = in.read(bytes)) > 0) {
digester.update(bytes, 0, byteCount);
}
return digester.digest();
} catch (Exception e) {
Log.e(e);
}
return null;
}
示例7: deleteDirContent
import ua.at.tsvetkov.util.Log; //导入依赖的package包/类
/**
* Delete content from directory
*
* @param pathName path for delete a content
*/
public static void deleteDirContent(@NonNull String pathName) {
File path = new File(pathName);
String[] files = path.list();
if (files != null) {
for (String fileName : files) {
File file = new File(fileName);
boolean result = file.delete();
if (result) {
Log.v("File success deleted " + fileName);
} else {
Log.w("Fail to delete file " + fileName);
}
}
}
}
示例8: deleteDir
import ua.at.tsvetkov.util.Log; //导入依赖的package包/类
/**
* Delete directory with a subdirs and a files
*
* @param dir directory for delete
* @return tue if success
*/
public static boolean deleteDir(File dir) {
if (dir == null) {
Log.e("Directory eq null - can't delete.");
return false;
}
if (dir.isDirectory()) {
String[] children = dir.list();
for (String element : children) {
boolean success = deleteDir(new File(dir, element));
if (!success) {
return false;
}
}
}
return dir.delete();
}
示例9: getFileLength
import ua.at.tsvetkov.util.Log; //导入依赖的package包/类
/**
* Returns the content length in bytes specified by the response header field content-length or -1 if this field is not set.
*
* @param url url path to file
* @return the value of the response header field content-length
*/
static public int getFileLength(String url) {
HttpURLConnection conn = null;
int length = 0;
try {
conn = (HttpURLConnection) new URL(url).openConnection();
conn.setRequestProperty("keep-alive", "false");
conn.setDoInput(true);
conn.setConnectTimeout(TIMEOUT);
conn.connect();
length = conn.getContentLength();
} catch (Exception e) {
Log.e(e);
} finally {
if (conn != null)
conn.disconnect();
}
return length;
}
示例10: getFileName
import ua.at.tsvetkov.util.Log; //导入依赖的package包/类
/**
* Return file name with extension without directories.
*
* @param fullPath full path to file
* @return file name or empty string if fullPath have not include the correct filename.
*/
public static String getFileName(String fullPath) {
String fileName = "";
if (fullPath == null) {
Log.w("The path to file is null");
return fileName;
}
if (fullPath.length() == 0) {
Log.w("The path to file is empty");
return fileName;
}
int indexOf = fullPath.lastIndexOf(File.separator);
if (indexOf == -1) {
return fullPath;
}
try {
fileName = fullPath.substring(indexOf + 1, fullPath.length());
} catch (IndexOutOfBoundsException e) {
Log.wtf("IndexOutOfBoundsException in " + fullPath);
}
return fileName;
}
示例11: getFileExtension
import ua.at.tsvetkov.util.Log; //导入依赖的package包/类
/**
* Return file extension
*
* @param fullPath full path to file
* @return file extension or empty string if fullPath have not include the correct filename or have empty extension.
*/
public static String getFileExtension(String fullPath) {
String fileName = "";
if (fullPath == null) {
Log.w("The path to file is null");
return fileName;
}
if (fullPath.length() == 0) {
Log.w("The path to file is empty");
return fileName;
}
int pos = fullPath.lastIndexOf(".");
if (pos != -1) {
fileName = fullPath.substring(pos + 1, fullPath.length());
}
return fileName;
}
示例12: getFilePath
import ua.at.tsvetkov.util.Log; //导入依赖的package包/类
/**
* Return path for this file without file name
*
* @param fullPath full path to file
* @return path without file name
*/
public static String getFilePath(String fullPath) {
String fileName = "";
if (fullPath == null) {
Log.w("The path to file is null");
return fileName;
}
if (fullPath.length() == 0) {
Log.w("The path to file is empty");
return fileName;
}
int pos = fullPath.lastIndexOf(File.separator);
if (pos != -1) {
fileName = fullPath.substring(0, pos + 1);
return fileName;
}
return "";
}
示例13: onCreate
import ua.at.tsvetkov.util.Log; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ac_main);
acMainListItems = (ListView) findViewById(R.id.acMainListItems);
acMainProgressLayout = (FrameLayout) findViewById(R.id.acMainProgressLayout);
acMainListItems.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.v("Monarch click");
}
});
adapter = new MonarchAdapter(this);
acMainListItems.setAdapter(adapter);
getData();
}
示例14: DataProcessorConfiguration
import ua.at.tsvetkov.util.Log; //导入依赖的package包/类
private DataProcessorConfiguration(final Builder builder) {
isLogEnabled = builder.isLogEnabled;
httpUserAgent = builder.httpUserAgent;
timeout = builder.timeout;
isThreadPoolEnabled = builder.isThreadPoolEnabled;
host = builder.host;
port = builder.port;
scheme = builder.scheme;
encoding = builder.encoding;
isCheckingRequestStringEnabled = builder.isCheckingRequestStringEnabled;
isShowProcessingTime = builder.isShowProcessingTime;
testServerUrl = builder.testServerUrl;
isCacheEnabled = builder.isCacheEnabled;
cacheSize = builder.cacheSize;
if (isLogEnabled) {
Log.i("========= Data Processor Configuration ==========");
Log.i("Host = " + scheme + host + port);
Log.i("Test url = " + testServerUrl);
Log.i("isShowProcessingTime = " + isShowProcessingTime);
if (isCacheEnabled) {
Log.i("isCacheEnabled = true, cacheSize = " + cacheSize);
} else {
Log.i("isCacheEnabled = false");
}
Log.i("httpUserAgent = " + httpUserAgent);
Log.i("=================================================");
}
}
示例15: getString
import ua.at.tsvetkov.util.Log; //导入依赖的package包/类
/**
* Returns the value mapped by name if it exists, coercing it if necessary,
* or empty if no such mapping exists and print warning in to LogCat.
*
* @param obj JSONObject
* @param name name of value
* @return String
*/
public String getString(JSONObject obj, String name) {
String result = null;
try {
result = obj.getString(name);
} catch (JSONException e) {
Log.w(this, name + " is not exist in this JSON object");
}
if (result == null || result.equals("null")) {
result = "";
}
return result;
}