當前位置: 首頁>>代碼示例>>Java>>正文


Java IOException.getStackTrace方法代碼示例

本文整理匯總了Java中java.io.IOException.getStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java IOException.getStackTrace方法的具體用法?Java IOException.getStackTrace怎麽用?Java IOException.getStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.io.IOException的用法示例。


在下文中一共展示了IOException.getStackTrace方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTextFromFile

import java.io.IOException; //導入方法依賴的package包/類
public static String getTextFromFile(String resourceFile) {
	StringBuilder sb = new StringBuilder();
	ClassLoader classloader = Thread.currentThread().getContextClassLoader();
	try (BufferedReader reader = new BufferedReader(
			new InputStreamReader(classloader.getResourceAsStream(resourceFile), StandardCharsets.UTF_8));) {
		reader.lines().forEach(line -> sb.append(line));
	} catch (IOException e) {
		throw new RuntimeException("Cannot read file with JSON " + e.getStackTrace());
	}
	return sb.toString();
}
 
開發者ID:redhat-developer,項目名稱:che-vertx-server,代碼行數:12,代碼來源:Utils.java

示例2: getTextFromFile

import java.io.IOException; //導入方法依賴的package包/類
public static String getTextFromFile(String responseFile) {
	StringBuilder sb = new StringBuilder();
	ClassLoader classloader = Thread.currentThread().getContextClassLoader();
	try (BufferedReader reader = new BufferedReader(
			new InputStreamReader(classloader.getResourceAsStream("test.csv")))) {
		reader.lines().forEach(line -> sb.append(line));
	} catch (IOException e) {
		throw new RuntimeException("Cannot read file with JSON response " + e.getStackTrace());
	}
	return sb.toString();
}
 
開發者ID:redhat-developer,項目名稱:che-vertx-server,代碼行數:12,代碼來源:Utils.java

示例3: setBinaryStream

import java.io.IOException; //導入方法依賴的package包/類
/**
 * 以指定指定長度將二進製流寫入OutputStream,並返回OutputStream
 * 
 * @param pos
 *            pos
 * @return OutputStream
 * @throws SQLException
 *             SQLException
 */
public OutputStream setBinaryStream(long pos) throws SQLException {
    // 暫不支持
    nonsupport();
    pos--;
    if (pos < 0) {
        throw new SQLException("pos < 0");
    }
    if (pos > _length) {
        throw new SQLException("pos > length");
    }
    // 將byte[]轉為ByteArrayInputStream
    ByteArrayInputStream inputStream = new ByteArrayInputStream(_bytes);
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    byte[] bytes = new byte[(int) pos];
    try {
        bytes = new byte[inputStream.available()];
        int read;
        while ((read = inputStream.read(bytes)) >= 0) {
            os.write(bytes, 0, read);
        }
    } catch (IOException e) {
        e.getStackTrace();
    }
    // 返回OutputStream
    return (OutputStream) os;
}
 
開發者ID:lftao,項目名稱:jkami,代碼行數:36,代碼來源:BlobImpl.java

示例4: Settings

import java.io.IOException; //導入方法依賴的package包/類
/**
 * constructor.
 */
public Settings() {
    ClassLoader loader = Settings.class.getClassLoader();
    try (InputStream is = loader.getResourceAsStream("app.properties")) {
        this.load(is);
    } catch (IOException ioe) {
        ioe.getStackTrace();
    }
}
 
開發者ID:istolbov,項目名稱:i_stolbov,代碼行數:12,代碼來源:Settings.java

示例5: Bot

import java.io.IOException; //導入方法依賴的package包/類
/**
 * constructor.
 * @param answersPath - answersPath
 * @throws IOException - IOException
 */
public Bot(String answersPath) throws IOException {
    try {
        this.botAnswers = Files.readAllLines(Paths.get(answersPath), StandardCharsets.UTF_8);
    } catch (IOException ioe) {
        ioe.getStackTrace();
    }
}
 
開發者ID:istolbov,項目名稱:i_stolbov,代碼行數:13,代碼來源:Bot.java

示例6: testReadWithCorruptPadding

import java.io.IOException; //導入方法依賴的package包/類
/**
 * corrupt the padding by inserting non-zero bytes. Make sure the reader
 * throws exception.
 */
@Test
public void testReadWithCorruptPadding() throws IOException {
  final RaftStorage storage = new RaftStorage(storageDir, StartupOption.REGULAR);
  File openSegment = storage.getStorageDir().getOpenLogFile(0);

  LogEntryProto[] entries = new LogEntryProto[10];
  LogOutputStream out = new LogOutputStream(openSegment, false,
      16 * 1024 * 1024, 4 * 1024 * 1024, bufferSize);
  for (int i = 0; i < 10; i++) {
    SimpleOperation m = new SimpleOperation("m" + i);
    entries[i] = ProtoUtils.toLogEntryProto(m.getLogEntryContent(), 0, i,
        clientId, callId);
    out.write(entries[i]);
  }
  out.flush();

  // make sure the file contains padding
  Assert.assertEquals(4 * 1024 * 1024, openSegment.length());

  try (FileOutputStream fout = new FileOutputStream(openSegment, true)) {
    ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[]{-1, 1});
    fout.getChannel()
        .write(byteBuffer, 16 * 1024 * 1024 - 10);
  }

  List<LogEntryProto> list = new ArrayList<>();
  try (LogInputStream in = new LogInputStream(openSegment, 0,
      RaftServerConstants.INVALID_LOG_INDEX, true)) {
    LogEntryProto entry;
    while ((entry = in.nextEntry()) != null) {
      list.add(entry);
    }
    Assert.fail("should fail since we corrupt the padding");
  } catch (IOException e) {
    boolean findVerifyTerminator = false;
    for (StackTraceElement s : e.getStackTrace()) {
      if (s.getMethodName().equals("verifyTerminator")) {
        findVerifyTerminator = true;
        break;
      }
    }
    Assert.assertTrue(findVerifyTerminator);
  }
  Assert.assertArrayEquals(entries,
      list.toArray(new LogEntryProto[list.size()]));
}
 
開發者ID:apache,項目名稱:incubator-ratis,代碼行數:51,代碼來源:TestRaftLogReadWrite.java


注:本文中的java.io.IOException.getStackTrace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。