当前位置: 首页>>代码示例>>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;未经允许,请勿转载。